Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Java An Introduction To Problem Solving And Programming

Authors: Walter Savitch

8th Edition

0134462033, 978-0134462035

More Books

Students also viewed these Programming questions

Question

In a system with light damping (c Answered: 1 week ago

Answered: 1 week ago