Hey!
I have a two classes and i have a rather hard time calling the second last method from the first class
so that the last method, which is a private, can react!
Not allowed to change the first class but the second one i can do as i please but no matter what i
still cannot get the right call from it.
This is the one that i'm not allowed to change.
public class AlarmClock { /* Current time */ private int hours = 0; private int minutes = 0; /* Alarm Properties */ private int alarmHour = 0; private int alarmMinute = 0; private boolean alarmOn = false; public AlarmClock(int h, int m) { hours = h; minutes = m; } public void displayTime() { System.out.println("Time: " + hours + " hours, " + minutes + " minutes"); } public void setAlarm(int h, int m) { alarmHour = h; alarmMinute = m; alarmOn = true; } public void displayAlarmTime() { System.out.println("Alarm Time: " + alarmHour + " hours, " + alarmMinute + " minutes"); } public void timeTick() { minutes = minutes + 1; if (minutes == 60) { hours = hours + 1; minutes = 0; } if (hours == 24) { hours = 0; } checkAlarm(); } private void checkAlarm() { if (alarmOn && minutes == alarmMinute && hours == alarmHour) System.out.println("Wake up! Time to go!"); } }
And this is my main.
public class AlarmMain { public static void main(String[] args) { AlarmClock A = new AlarmClock(23, 48); A.setAlarm(6, 15); A.displayTime(); A.displayAlarmTime(); A.timeTick(); } }
And what i need to be able to do is to add 500 more min so that the call from "A.timeTick()" reacts.
The time that is set is 23:48.
I have tried to add more time onto the "new AlarmClock(h, m)" by adding
on m within a forloop but that didn't work.
Any idea as of how i should go about fixing this?