Customer The Customer class implements the \"Comparable\" interface . (The Compa
ID: 3553560 • Letter: C
Question
Customer
The Customer class implements the "Comparable" interface. (The Comparable interface is defined in the "java.lang" package.)
public int compareTo(Object other)
If the current object has the last name lexicographically less than that of the argument, an int less than zero is returned. If the current object has the last name greater than the argument, an int greater than zero is returned. If both objects have the same last Name, their first names should be compared.
The Customer class also implements the "Serializable" interface so that its object can be stored. (The Serializable interface is defined in the "java.io" pakcage.)
CPU
The CPU class implements the "Comparable" interface. In addition to the attributes and methods provided, the following method must be defined:
public int compareTo(Object other)
If the current object has the CPU type lexicographically less than that of the argument, an int less than zero is returned. If the current object has the CPU type greater than that of the argument, an int greater than zero is returned. If both objects have the same CPU type, their CPU speed should be compared.
The CPU class also implements the "Serializable" interface so that its object can be stored.
Computer
The Computer class implements the "Comparable" interface.
public int compareTo(Object other)
If the current object has the brand name lexicographically less than that of the argument, an int less than zero is returned. If the current object has the brand name greater than that of the argument, an int greater than zero is returned. If the both objects have the same brand name, their CPU should be compared using the compareTo method of the CPU class. If the both objects have the same brand name and CPU, then their memory should be compared.
The Computer class also implements the "Serializable" interface.
Explanation / Answer
Find the code here : http://ideone.com/a8NdKK
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.