Question: Define a full class called Time with three instance variables hour (int), minute (int) and period (String with value of AM or PM). Define a
Define a full class called Time with three instance variables hour (int), minute (int) and period (String with value of AM or PM).
Define a constructor without parameters that set default value to 0 hour 0 minute AM.
Define a parameterized constructor that take three initial values to initialize all instance variables.
Define a toString method that return (not print) a String like: "Stored time is 1:20AM".
Define an isValidPeriod method that takes no parameter and return true if the period instance variable equals "AM" or equals "PM". (hint: how to check equality between Strings?)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
