Question
I'm not really getting the output I'm looking for. Could someone adjust my code and help explain? Design a class that holds the following personal
I'm not really getting the output I'm looking for. Could someone adjust my code and help explain?
Design a class that holds the following personal data: name, address, age, and phone number. Write appropriate accessor and mutator methods (get and set). Write a program that creates three instances of the class. One instance should hold your information and the other two should hold your friends or family members' information. Just add information, don't get it from the user. Print the data from each object, make sure to format the output for clarity and ease of reading.
class Person: def __init__(self, name, address, age, phone): self._name = name self._address = address self._age = age self._phone = phone def set_name(self, name): self._name = name def set_address(self, address): self._address = address def set_age(self, age): self._age = age def set_phone(self, phone): self._phone = phone def get_name(self): return self._name def get_address(self): return self._address def get_age(self): return self._age def get_phone(self): return self._phone def main(): p1 = Person("Justin", "1 MG Road", 27, "8153073035") p2 = Person("John", "2 Bay Road", 15, "8153093939") p3 = Person("Ben", "3 Sun Road", 15, "8152342345") print("Three instances have been created.") print(p1) print(p2) print(p3) main()
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started