この長さと引数のサイズの合計と同じサイズの新しい長さを返す add(Length) メソッドを作成する必要があります。double または Length を返す必要があるかどうか、および追加する方法がわからない
public class Length implements Comparable<Length>{
private final double length; //private! Do NOT add a getter
// This constructor must remain private
private Length(double l){
length = l;
}
public double add(Length l){
return ;
}
public double subtract(Length l){
}
public double scale(double d){
}
public double divide(Length l){
}
public double Length(Position one, Position two){
}
// TODO: For all constants, have a line:
// public static final Length ... = new Length(...);
// Use the @Override annotation on all methods
// That override a superclass method.
@Override
public boolean equals(Object other){
//TODO
}
@Override
public int hashCode(){
//TODO
}
@Override
public String toString(){
//TODO
}
// If you are overriding a method from an interface, then Java 5
// says you CANNOT use Override, but Java 6 says you MAY. Either is OK.
// @Override
public int compareTo(Length other) {
//TODO
}
// TODO Write the rest of the methods for this class, and
// the other two classes.
}