compareTo and equals methods for a 24 hour clock program in Java

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter5: Making Decisions
Section: Chapter Questions
Problem 8PE
icon
Related questions
Question

compareTo and equals methods for a 24 hour clock program in Java

 

 

 

public int compareTo (Clock24 other)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than
the specified object.
Parameters:
other - the object to be compared.
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
Transcribed Image Text:public int compareTo (Clock24 other) Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. Parameters: other - the object to be compared. Returns: a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
public boolean equals (Object other)
Compares this ClockModel object to another object. If the specified object is a ClockModel, and if it has the same state as this object, the method returns true;
otherwise, it returns false.
Overrides:
equals in class Object
Parameters:
other - An object to which to compare
Returns:
true if other is a ClockModel that has the same state as this object; false otherwise.
Transcribed Image Text:public boolean equals (Object other) Compares this ClockModel object to another object. If the specified object is a ClockModel, and if it has the same state as this object, the method returns true; otherwise, it returns false. Overrides: equals in class Object Parameters: other - An object to which to compare Returns: true if other is a ClockModel that has the same state as this object; false otherwise.
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Multithreading Methods
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,