Skip to content

stillHere3000/JavaII

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Getting Started

Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code.

Repo Structure

The workspace contains two folders by default, where:

  • src: the folder to maintain sources
  • lib: the folder to maintain dependencies

Meanwhile, the compiled output files will be generated in the bin folder by default.

If you want to customize the folder structure, open .vscode/settings.json and update the related settings there.

Dependency Management

The JAVA PROJECTS view allows you to manage your dependencies. More details can be found here.

Lab Two

Design a class named Timer that contains the following three private instance data fields: hours: an integer that holds the number of hours. minutes: an integer that holds the number of minutes. seconds: an integer that holds the number of seconds.

In addition, the class should have the following constructors and methods: 1. A no-arg constructor that creates a default Timer object (The data fields hours, minutes, seconds are defaulted to 0). 2. A constructor that constructs a Timer object with three specified values for hours, minutes, and seconds. 3. Three public setter methods for the data fields hours, minutes and seconds. 4. Three public getter methods for the data fields hours, minutes and seconds.

In the second constructor and three setter methods above, make sure that the three data fiel Write a test program to do the following tasks: 1. Prompt the user to enter three groups of values of hours, minutes and seconds and use the 2. Calculate and print the total number of hours, minutes, and seconds in these three object A sample dialog is: Enter the first Timer object: 1 2 3 Enter the second Timer object: 4 5 6 Enter the third Timer object: 7 8 -1 The total number of hours is 12 (sum of 1, 4 and 7) The total number of minutes is 15 (sum of 2, 5, and 8) The total number of seconds is 9 (sum of 3, 6 and 0)

About

Second Semester of Java

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages