Please remember that homework must be handed in on time. No late homework will be accepted.
ls cd Desktop/MyWorkspace/BookShelf/src javac *.java java RemoveTester1
java SquareGenerator 9
your program should output 81. If the user supplies no command line arguments or more than 1 command line argument, output the error message "INVALID USAGE" instead.
Shape
/ \
Circle Polygon
/ \
Triangle Parallelogram
|
Rectangle
|
Square
For example, Square is a subclass of Rectangle, so every instance of Square inherits all of the properties and behaviors of its superclass Rectangle. Rectangle inherits from Parallelogram, and Triangle and Parallelogram are both subclasses of Polygon, and so on. For the following list of objects, draw a diagram similar to the diagram above that indicates the class hierarchy of these objects with respect to one another using the principle of inheritance. (Each class should have no more than one superclass.)
Amphibian Animal Bee Bird Bumblebee Cardinal Dog Eagle Fish Frog Human Insect Invertebrate Mammal Mosquito Reptile Snake Vertebrate Whale
public class Time implements Comparable
{
private int hour; // an integer between 0 and 23
private int minute; // an integer between 0 and 59
public Time(int hourNum, int minuteNum) {
// creates a Time with the given hourNum and minuteNum if valid
// otherwise creates the Time 00:00
if (hourNum < 0 || hourNum > 23 || minuteNum < 0 || minuteNum > 59) {
hour = 0;
minute = 0;
}
else {
hour = hourNum;
minute = minuteNum;
}
}
public int getHour() {
return hour;
}
public int getMinute() {
return minute;
}
// other methods not shown
}
The Time class inherits from the Object class in Java. Two Time instances are equal if they have the same hour and the same minute.
public int compareTo(Object obj) {
Time otherTime = (Time) obj;
// complete the rest of this method:
}