Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

SOS I NEED HELP This is in Java 1. Write a class called Clock. Here are the first few lines: public class Clock ( //

SOS I NEED HELP
This is in Java image text in transcribed
image text in transcribed
1. Write a class called Clock. Here are the first few lines: public class Clock ( // instance variables private int hour; private int minute; private int second; Write a default constructor for a 12-hour Clock that initializes hour, minute, and second to zero. Write accessors and mutators for all instance variables Write a toString method that will return a String representation of a Clock object using the format hour : minute second Each integer should occupy 2 digits. For example, if hour contains 12, minute contains 5, and second contains 9, the tostring method should return the String "12:05:09". In this example, you need to insert a 'o' character before the minutes and also before the seconds. Write a method called tick that will increment the number of seconds, then check to see that second, minute, and hour contain valid data. Adjust the instance variables as needed. Write an equals method that will return true if the Clock parameter has the same hour, minute, and second as the calling object

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Management Systems

Authors: Patricia Ward, George A Dafoulas

1st Edition

1844804526, 978-1844804528

Students also viewed these Databases questions