IC211 Spring 2019
Name (Last, First): ____________________________________________________ Alpha: _____________________
Describe help received: _________________________________________________________________
[20Pts] What's wrong with the function disp() defined below?
public class Foo {
double x;
String s;
public static String disp() {
return "[" + s + "," + x + "]";
}
}
[60Pts] Given the following (partial) defintion of class Time
public class Time {
int hh, mm, ss;
public boolean equal(Time t) { ... }
public static boolean equal(Time t1, Time t2) { ... }
}
Assume code in some other method of class Foo defines A and B as:
Time A = new Time(), B = new Time();
How would you call the first definition of equal to compare A and B?
How would you call the second definition of equal to compare A and B?
Give the definition for the first "equal":
public boolean equal(Time t) {
}
public static boolean equal(Time t1, Time t2) {
}
[20Pts] Suppose I wanted to add a function to the Time class (above) to determine whether Time A comes before Time B. Give the complete method definition I would have to add to the Time class in order to be able to call the function like this:
A.isBefore(B)