FYI - This is my first post. This is an assignment for a JAVA I class. I cannot import anything or change the public class. My problem right now focusing on the ADVANCE method, I don't know how to advance the day. So my question is how should I get a if/then, for, or while component in there to anchor my advancing minutes to my days?
public class ClockDriver { public static void main(String[] args) { Clock MyClock = new Clock("Thursday", 12,0); // Instantiate a clock object System.out.println(MyClock); // Should display: Thursday, 12:00 p.m. System.out.println(); // print blank line MyClock.advance(150); // advance time 150 minutes (2 hours 30 minutes) System.out.println(MyClock); // Should display: Thursday, 2:30 p.m. System.out.println(); MyClock.advance(585); // advance time by 585 minutes (9 hours 45 minutes) System.out.println(MyClock); // Should display: Friday, 12:15 a.m. System.out.println(); MyClock.advance(10080); // advance time by 10080 minutes (7 days) System.out.println(MyClock); // Should display: Friday, 12:15 a.m. System.out.println(); MyClock.reverse(585); // reverse time by 585 minutes (9 hours 45 minutes) System.out.println(MyClock); // Should display: Thursday, 2:30 p.m. System.out.println(); MyClock.reverse(17280); // reverse time by 17280 minutes (12 days) System.out.println(MyClock); // Should display: Saturday, 2:30 p.m. System.out.println(); } // end of main } // end of class ClockDriver class Clock{ /*************************************************************** * Objects of this class represent time (in hours and minutes) * * The time data is stored in 24 hour (HHMM military format) * ***************************************************************/ private int day_of_week; // valid range of values is 1 thru' 7 private int hours; // range of values is 0 thru' 23 private int minutes; // range of values is 0 thru' 59 private String[] dow = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; public Clock(String s, int h, int m){ //Initialize day_of_week, hours and minutes - 20 points if (s.equals("Sunday")) { day_of_week = 1; } else if (s.equals("Monday")) { day_of_week = 2; } else if (s.equals("Tuesday")) { day_of_week = 3; } else if (s.equals("Wednesday")) { day_of_week = 4; } else if (s.equals("Thursday")) { day_of_week = 5; } else if (s.equals("Friday")) { day_of_week = 6; } else if (s.equals("Saturday")) { day_of_week = 7; } else { day_of_week = -1; } hours = h; minutes = m; } public void advance(int m){ // advance day_of_week, hours and minutes - 30 points int allMinA = (hours * 60) + minutes + m; minutes = allMinA % 60; hours = (allMinA / 60) % 24; } public void reverse(int m){ // reverse day_of_week, hours and minutes - 30 points int allMinB = (hours * 60) + minutes - m; minutes = allMinB % 60; hours = (allMinB / 60) % 24; } public String toString(){ //return Day of the week, hours and minutes as a string to be displayed - 20 points if (hours >12){ hours = hours - 12; } String result = dow[day_of_week - 1] + ", " + String.format("%2d", hours) + ":" + String.format("%02d", minutes) + " amORpm > "; return result; } } // end of class Clock