0

Write a class named Person with data attributes for a person’s name, address, 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 mailing list. Demonstrate an instance of the Customer class in a simple program.'

This is what I have for my code, but I keep getting the following error:

Traceback (most recent call last):
 File "/Users/ryanraben/Desktop/person1.py", line 45, in <module>
 import customer
ModuleNotFoundError: No module named 'customer'

I have been struggling with this class this semester. I found someone asking a similar question here in Stack Overflow but their code was very different than what I had (and if I copied their code I still could not get the correct results). This was a video module and I entered my code as it appeared on the instructor's screen, but obviously I didn't do it right because his code works and mine does not.

class Person:
 def __init__(self, name, address, phone):
 self.__name = name
 self.__address = address
 self.__phone = phone
 def set_name (self, name):
 self.__name = name
 def set_address (self, address):
 self.__address = address
 def set_phone (self, phone):
 self.__phone = phone
 def get_name (self):
 return self.__name
 def get_address (self):
 return self.__address
 def get_phone (self):
 return self.__phone
class Customer (Person):
 def __init__(self, name, address, phone, customer_number, mailing_list):
 Person.__init__(self, name, adress, phone)
 self.__customer_number = customer_number
 self.__mailing_list = mailing_list
 def set_customer_number (self, customer_number):
 self.__customer_number = customer_number
 def set_mailing_list(self, mailing_list):
 self.__mailing_list = mailing_list
 def get_customer_number(self):
 return self.__customer_number
 def get_mailing_list (self):
 return self.__mailing_list
import customer
name = input ('Name: ') 
address = input ('Address: ')
phone = input ('Phone: ')
customer_number = input ('Customer number: ')
mail = input ('Include in mailing list? (y/n): ')
if mail.lower()=='y':
 mailing_list = True
else:
 mailing_list = False
my_customer = customer.Customer (name, address, phone, customer_number, mailing_list) 
print ('Customer Information')
print ('-----------------------------')
print ('Name: ', my_customer.get_name())
print ('Address: ', my_customer.get_address())
print ('Phone: ', my_customer.get_phone())
print ('Customer number: ', my_customer.get_customer_number())
print ('Mailing list: ', my_customer.get_mailing_list())
asked Apr 15, 2017 at 22:36
2
  • I'm sorry. This programming stuff is all Greek to me. I thought it was the easiest way to explain what I was doing. My apologies, and thank you for the help below. Commented Apr 15, 2017 at 22:47
  • 1
    No worries, we were all new once, I'm glad to help! Welcome to the community Commented Apr 16, 2017 at 1:40

2 Answers 2

1

This is a pretty common error:

You're attempting to import the library of customer and your IDE is simply not able to find this file.

Since you're defining the Class Customer I can't see any reason why you would need to import this non-existant library.

Consequently, I suggest you delete the line import customer.

That is unless I've misunderstood something.

answered Apr 15, 2017 at 22:41
Sign up to request clarification or add additional context in comments.

Comments

0

remove this line(import customer) and remove customer from 'customer.Customer' while creating the object. After all of this you have error of 'adress' not defined. Find this attribute in your code and change it to address. Thats All dear.

answered Feb 14, 2022 at 11:43

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.