Question: Need help in Java with a Time Class and a Class with a main method to test time objects Time objects are: Code:Time time1 =

Need help in Java with a Time Class and a Class with a main method to test time objects

Time objects are:

Code:Time time1 = new Time(2:30);

Expected result: time 1 object created with hours: 2 and minutes: 30

Code: Time time2 = new Time (2,45, "PM");

Expected result: time 2 object created with hours: 14 and minutes: 45

Code: Time time3 = new Time (14,45);

Expected result: time3 object created with hours: 14 and minutes: 45

Code Time time4 = new Time(25,50);

Expected result: time 4 object created with hours: 0 and minutes: 0 (midnight - because of invalid input

Code time3.setMinutes(68);

Expected result: time 3 object not changed because of invalid input.

Code: System.out.println(time3.equals(time2));

Expected result: true printed to console

Code: System.out.println(time3)// calls time3.toString() automatically

Expected result:

14:45 printed to console

System.out.println(time3.get12HourTime());

Expected result: 2.45 PM printed to console

Creating and testing the Time class

You will be implementing the Time class in Time.java and a TimeTester.java program. Write these two files in small alternating pieces, using the TimeTester.java (and the debugger) to test your work in the Time class one step at a time.

Expectations for the Time class

It will meet all the requirements from the pre-lab.

Make sure that you comment your methods appropriately.

Make sure that all of your names in the Time class are correct according to the instructions and Java conventions, because the class will be tested also with a file you have not seen.

Testing the Time class

TimeTester.java should implement the sample tests provided with the pre-lab instructions, plus at least two additional tests per method that test different things from the sample tests (and each other). You should have created these additional tests for your pre-lab, but you may change them if needed.

For each test, you must output what the test is plus both the expected result of the test and the actual result of doing the test to the console. So someone reading your output should easily see what you tested, what should have happened, and what did happen for each test.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!