Sorry...The title is misleading, I do not want you to do the homework for me at all...but rather help me understand what I have to do. I've been working on this program for 3 hours trying to understand what my teacher wants us to do. It may just be the wording he is using but I'm having a hard time understanding exactly what he wants this program to accomplish. We have just started to learn about oop and this is my first assignment implementing that type of procedure so bare with me. If you all could take a look at my assignment and maybe explain to me what he wants or just try and clarify what I have to do, it would greatly be appreciated. Thanks
• Our first OOP consists of two classes – Time and TimeApp. The class Time represents the time of day. The class TimeApp is an application class in which the main method creates one object of class Time and invokes its methods. These classes must be declared in separate files because they are both public classes.
• The class Time contains 3 private instance variables of type int – hour, minute and second – that represent the time in military–time format (24-hour clock format in which hours are in the range 0-23). The class Time also contains four public methods Time (constructor), setTime, displayMilitary, and displayStandard. These methods are also called the public services or the public interface that the class provides to its clients.
• Here is the class Time design using UML:
- hour: int
- minute: int
- second: int
+ Time ( ) :
+ setTime (h,m,s: int) : void
+ displayMilitary ( ) : void
+ displayStandard ( ) : void
• Here is the partial Class Time definition:
// File name: Time.java
// Time class maintains the time in 24-hour format.
public class Time
// Instance fields (variables)
private int hour; // 0-23
private int minute; // 0-59
private int second; // 0-59
// Instance methods
public Time ( int , int, int) // Constructor
// sets the starting hour, minute, and second at 0.
public void setTime (int h, int m, int s)
// stores values passed as argument in the fields.
public void displayMilitary ( )
// display in military-time format (e.g., 14:20:26 )
public void displayStandard ( )
// display in standard-time format (e.g., 1: 25:05 AM or PM)
} // end of class
• Complete the Time class definition
• Write the TimeApp (file name: TimeApp.java ) application class (including the main method) that involves the following activities:
- create and initialize a Time object.
- output string representations of the time.
- change time and output updated time.
- set time with invalid values: output updated time.
Your program output will look just like the following to receive full credit.
The initial military time is: 00:00:00
The initial standard time is: 12:00:00 AM
Military time after setTime is: 13:27:06
Standard time after setTime is: 1:22:06 PM
After attempting invalid setting:
Military time: 00:00:00
Standard time: 12:00:00 AM