class SimpleTime3 { int hour, minute; /* Multiple constructors can be convenient for the client. */ SimpleTime3 (int h) { this(h,0); } SimpleTime3 (int h, int m) { this.hour=h; this.minute=m; } /* It is often helpful for debguging to have a printable represenation of the value of the data structure. It is traditional and useful to call such a method "toString()". */ @java.lang.Override public String toString () { if (hour==0 && minute==0) { return ("midnight"); } else if (hour==12 && minute==0) { return ("noon"); } else { return String.format ("%02d:%02d", hour, minute); } } public static void main (String [] args) { SimpleTime3 t = new SimpleTime3 (12); System.out.println (t); SimpleTime3 s = new SimpleTime3 (7,12); System.out.println (s.toString()); SimpleTime3 r = new SimpleTime3 (18,53); System.out.println (r); } /* Notice that call 'toString()' is unnecessary as 'println()' does that for us. */ }