We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1
Write an OOP Pyhton code to create class called ( Clock )
with 3 attributes as follows:
1- make constructor ( __init__ ) to create this class ( Clock ) 3 attributes: ( hrs ) as hidden and private attribute ( min ) as protect attr. ( sec ) as public attr. 2- Make ( sethrs ) method to enter new value for private (hrs) attribute Make ( gethrs ) method to print out the value of (hrs) attribute 3- make a ( Noon ) method to calcuate and return the noon of time so, it will return 'AM' if hrs < 12 and return 'PM' if hrs >= 12 4- create two object from class ( Clock ) as follows 1) c1= Clock(11, 35, 46) 2) c2=Clock(23,35,46) 5- Print out each object using __str__ method as follows: [ The Clock is [ hh:mm:ss AM ] for c1.Clock() ==> [ 11:35:46 AM ] for c2.Clock() ==> [ 23:35:46 PM ] 6- implement show(self) method to print out the __str__ 7- make a ( arrival_Time ) method that received c1 and 95 as arrival_Time (self - c1 ,other = 95 minutes) then it return the c3 , which is the clock when arrival time. for Example other = 95 minutes = 1 hr + 35 minutes ( using __add__ ) c3 = c1 + 95 = 12:35:46 + 95 minutes = 13:10:46