Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python only. All files needed are in the below link: https://www.cse.msu.edu/~cse231/Online/Labs/Lab12/ Only one needed if I am correct is clockDemo.py Part B: Class Time You

image text in transcribedimage text in transcribedimage text in transcribed

Python only. All files needed are in the below link:

https://www.cse.msu.edu/~cse231/Online/Labs/Lab12/

Only one needed if I am correct is clockDemo.py

Part B: Class Time You will develop a new data type to model the time on a 24 hour clock, where the three data members represent the hour, the minutes and the seconds. Use the date.py module as a guide. It will be named "class Time and each object of that type will have three instance variables hour mins" and Secs The module will be named "clock.py" 1. Develop the function member (method) named init which will be used to initialize an object of type "Time" when it is created. That function will receive four parameters: a reference to the current object ("self), the hour, the minutes and the seconds. a. Assume that the last three of the four parameters are integers. b. Use a default value of 0 for those last three parameters. c. Assign those last three parameters to the three instance variables. d. Add a "doc string" to the constructor documenting the purpose of the function. 2. Save the file containing your class as "clock.py', then experiment with your module in the iPython shell: import clock help clock help clock. Time A clock. Time print A 3. Develop the function member named repr which will be used to display the formal representation of an object of type "Time" in the Python shell a. Return a string with the format "Class Time hh mm: SS b. Be sure to place leading zeroes in the string for the hour, minutes and seconds. c. Add a "doc string" to the constructor documenting the purpose of the function. 4. Save the file containing your class as "clock.py", then experiment with your module in the iPython shell

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

Advanced MySQL 8 Discover The Full Potential Of MySQL And Ensure High Performance Of Your Database

Authors: Eric Vanier ,Birju Shah ,Tejaswi Malepati

1st Edition

1788834445, 978-1788834445

More Books

Students also viewed these Databases questions