I'm already build this program but get error...anyone can check for me?..tq
public class Clock
{
private int hour;
private int minute;
private int second;
public Clock (int hour, int minute, int second)
{
this.hour = hour;
this.minute = minute;
this.second = second;
}
public Clock (Int hour, int minute)
{ this.hour = hour;
this.minute = minute;
this.second = 0;
}
public Clock (int hour)
{
this.hour = hour;
this.minute = 0;
this.second = 0;
}
public Clock ()
{
this.hour = 0;
this.minute = 0;
this.second = 0;
}
public void yang ()
{
if (getSecond () == 59)
{
setSecond (0);
if ( getMinute () == 59)
{
setMinute (0);
if (getHour () == 23)
setHour (0);
else setHour (getHour () +1);
}
else setMinute (getMinute () +1);
}
else setSecond (getSecond () +1);
}
public int getHour ()
{
return hour;
}
public void setHour (int hour)
{
this.hour = hour;
}
public int getMinute ()
{
return minute;
}
public void setMinute (int minute)
{
this.minute = minute;
}
public int getSecond ()
{
return second;
}
public void setSecond (int second)
{
this.second = second;
}
public String toString ()
{
String currentTime = "Current Time:";
if (getHour ()> 9) currentTime + = getHour ();
else currentTime + = "0" + getHour ();
if (getMinute ()> 9)
currentTime +=":"+ getMinute ();
else currentTime + = ": 0 "+ getMinute ();
if (getSecond ()> 9)
currentTime +=":"+ getSecond ();
else currentTime + =": 0 "+ getSecond ();
return currentTime;
}
public static void main (String [ ] Args)
{Clock c1, c2; c1 = new Clock (22,59,59);
System.out.println ("c1 instance" + c1.toString ()); c1.yang (); System.out.println ("C1 instance" + c1.toString ()); c2 = new Clock (23,59); System.out.println ("c2 instance" + c2.toString ()); c2.yang (); System.out . Println ("c2 instance" + c2.toString ());
}
}