Laboratory Experiment 2
Programming Paradigms/Object Oriented Design
CPE106L
3Q1920Info! Broken links? Email us at gtechphofficial@gmail.com
Prelab
3. Class B extends class A. Class B defines an _str_ method that returns the string representation of its instance variables. Class B defines a single instance variable named age, which is an integer. Write the code to define the _str_ method for class B. This method should return the combined string information from both classes. Label the data for age with the string "Age: ".
class A:
def __init__(self):
self.message = "This is from Class A\n"
def __str__(self):
return self.message
class B(A):
def __init__(self):
super().__init__()
self.age = 18
def __str__(self):
return super().__str__() + "Age: " + str(self.age)
b = B()
print(b)
Inlab
4. The ATM program allows a user an indefinite number of attempts to log in. Fix the program so that it displays a popup message that the police will be called after a user has had three successive failures. The program should also disable the login button when this happens.
# Other codes soon.
Laboratory Report: Click here to download