Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

There is more part and I will send you on text Part 1 (10 points): Create a class, ClockOK. The ClockOK class has the following

There is more part and I will send you on text

image text in transcribed
Part 1 (10 points): Create a class, ClockOK. The ClockOK class has the following attributes, also called "data members": hour minute second The ClockOK class should have the following methods: init (hr, min, sec) This is the initializer or constructor. It is automatically called when a new instance of a ClockOK is created. Example: myClockOK = ClockOK(8, 15, 30) setHour(hr) This is a mutator, or setter. It sets the hour of the clock. getHour() This is an accessor. It returns the clock's hour. setMinute(min) Another mutator. It sets the minute of the clock. getMinute() Another accessor. It returns the clock's minute value. setSecond(sec) Mutator; it sets the second of the clock. getSecond() Accessor; it returns the clock's second value. _str_() This converts the class into a string for printing. Example: print(myClockOK) outputs: hours=8, minutes=15, seconds=30 Example: time = str(myClockOK); sets time to "hours=8, minutes=15, seconds=30" To test your class ClockOK, create a few instances of ClockOK. Set it to a time. For example: stopwatch = ClockOK(1, 15, 0); watch = ClockOK(6, 45, 18); Test each method by changing the value of the hour, minute and second of each instance of ClockOK. Get each value with the accessors. Finally, print each instance to verify the _ str_ _method. The methods will need the self parameter. See Chapter 10 for implementation details. A good example is class BankAccount, program 10-7 on page 537 (5ed), page 505 (4ed). It shows an example using all the techniques for this lab, but the number stored is a bank balance, not hours, minutes, and seconds. You could start with class BankAccount in file bankaccount.py and modify it into class ClockOK. After you have this working, for safety, you can save this part to the file; DDHH_L10_Lastname_ClockOK_p1.py (Customize DDHH and Lastname.)

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

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions