A computer program is to be developed to be used in clocks. Here is a class definition for this program

public class Time
{
     public int hour;
     public int minute;
     public boolean isMorning;
}

Enhance the above class definition by providing two constructors: one that allows a time to be set to given values; and another that sets a default time of 1 O’clock in the morning.

heres my code:

public class Time
{
     public int hour;
     public int minute;
     public boolean isMorning;

     public Time()

     {

      int hour= 1;
      int minute= 00;



      }



     public Time(int h, int m)


   {
      hour=h;
      minute=m;

  }


     public void printTime()
     {
         System.out.println(hour + ":" + minute);
}

}

would my code be right?
i keep getting error messages which i dont understand why

thanks

Well, the error message says why. Did you read it? It also indicates the line on which the error occurred.

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.