0% found this document useful (0 votes)
4 views1 page

Class Design - ComboLock

Uploaded by

rajashreesabale4
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Class Design - ComboLock

Uploaded by

rajashreesabale4
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

ComboLock class implementation

Implement a class ComboLock that works like the combination lock in a gym
locker, as shown here. The lock is constructed with a combination—three
numbers between 0 and 39. The reset method resets the dial so that it points
to 0. The turnLeft and turnRight methods turn the dial by a given number of
ticks to the left or right. The open method attempts to open the lock. The lock
opens if the user first turned it right to the first number in the combination,
then left to the second, and then right to the third.

A template for the class is given below. You can add any other required
attributes to the class but it should have the following methods.

class ComboLock :

def ComboLock(self, secret1, secret2, secret3) :

...

def reset(self) :

. . .

def turnLeft(self, ticks) :

. . .

def turnRight(self, ticks) :

. . .

def open(self) :

. . .

Impetus IT Services Pvt.Ltd.


B-16, First floor, Sant Tukaram Vyapar Sankul, Sector - 24, Nigdi, Pune, Maharashtra. India. Pin – 411044.
Mobile 9970600774, 9730012775|Board 91-20-27640406|Fax 91-20-27641703
Email : [email protected] | Website : www.impetusits.in

You might also like