Name: ____________________________________________________ Alpha: _____________________

Describe help received: _________________________________________________________________

  1. [20Pts] What's wrong with the function disp() defined below?
    public class Foo
    {
      double x;
      String s;
      public static String disp()
      {
        return "[" + s + "," + x + "]";
      }
    }
  2. [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 class Foo class defines A and B as: Time A = new Time(), B = new Time();
    1. How would you call the first definition of equal to compare A and B (still from Foo)?
    2. How would you call the second definition of equal to compare A and B (still from Foo)?
    3. Give the definition for the first "equal":
      public boolean equal(Time t) 
      {
      
      
      
      }
    4. Give the definition for the second "equal":
      public static boolean equal(Time t1, Time t2) 
      {
      
      
      
      }
  3. [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)