Then we define a class that implements that interface:
// Constructor template for UTC1:
// new UTC1 (h, m)
// Interpretation:
// h is the hour (between 0 and 23, inclusive)
// m is the minute (between 0 and 59, inclusive)
class UTC1 implements UTC {
int h; // the hour, limited to [0,23]
int m; // the minute, limited to [0,59]
// the Java constructor
UTC1 (int h, int m) {
this.h = h;
this.m = m;
}
// public methods
// Returns the hour, between 0 and 23 inclusive.
public int hour () { return h; }
// Returns the minute, between 0 and 59 inclusive.
public int minute () { return m; }
// Returns true iff the given UTC is equal to this UTC.
public boolean isEqual (UTC t2) {
return (h == t2.hour()) && (m == t2.minute());
}
...
}