In: Computer Science
Write a class named Person with data attributes for a person’s first name, last name, and telephone number. Next, write a class named Customer that is a subclass of the Person class. The Customer class should have a data attribute for a customer number and a Boolean data attribute indicating whether the customer wishes to be on a calling list. Demonstrate an instance of the Customer class in a simple program.
Using python
Explanation:
Here is the code which has the class Person with the attributes firstname, last name, and the phone number.
Then, the class Customer is inherited from the Person class with extra attributes customer number and wishing Boolean value.
Code:
class Person:
def __init__(self, first, last, phone):
self.first = first
self.last = last
self.phone = phone
class Customer(Person):
def __init__(self, first, last, phone, cust_no, wishing):
Person.__init__(self, first, last, phone)
self.cust_no = cust_no
self.wishing = wishing
c = Customer("John", "Well", 123, 1, True)
PLEASE UPVOTE IF YOU FOUND THIS HELPFUL!
PLEASE COMMENT IF YOU NEED ANY HELP!