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 ());

}

}

If I may help, mind to describe a little bit of what the error is. Based on your posted code, the one error that I can find simply by scheming it is on your line 105

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 ());

I supposed you know how to fix it. If your error is not a technical error like the one that I discovered above, which means it is a logical error maybe you can help people who wanna help you in this forum by elaborating more your "error".

i got error message " illegal start of expression"
at line 88,89,93,97


can u try to help me?...

Friend, the error is just simply because you put space in between + and =

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 ();

mmm...still get error message like before oo

ok...u r awesome...settel....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.