i messed up
2010-01-26 07:47:28 UTC
public class clock {
private int hour;
private int minute;
private int second;
//instance variables for the alarm
private int Ahour;
private int Aminute;
private int Asecond;
public clock(){
hour = 0;
minute = 0;
second = 0;
}
public clock (int h, int m, int s){
hour =h;
minute = m;
second = s;
}
public void setAlarm (int h, int m, int s){
Ahour = h;
Aminute = m;
Asecond = s;
}
public void alarmNoise (){
System.out.println("WAKe up") ;
}
public void reset () {
hour = 0;
second = 0;
minute = 0;
}
//public String toString() {
//String str =("%02d:%02d:02d", hour, minute, second);
//}***get help with this part
public void advance(){
if(hour==Ahour){
if(minute==Aminute)
if(second==Asecond)
alarmNoise();
}
if(second>=0){
second++;
if(second==60)
second = 0;
minute++;
if(minute==60)
minute = 0;
hour++;
if(hour==24)
hour = 0;
}
}
}
I need help finishing my toString method. It should put the current time in the form "hh:mm:ss"
Any advice would be greatly appreciated.