dil_bert Posted May 1, 2019 Share Posted May 1, 2019 hello dear Experts i am going to create a Phonebook class efforts and parts: Design a Python class for a Phonebook. You class should have the following methods - see the little list that i have to implement: init (self): creates an empty list to store names and numbers Add(self, name, number): adds the name and number to the list Display(self): displays the entire phonebook. Find(self, name): this should find and also do the print of the number in the little phonebook that is associated with the name last but not least i want to add more stuff: eg. Add a main() method that ddoes more - eg. to the script that adds a couple of new phone entries and calls the display() and besides of this additionaly find() methods to see if they work. so far so good: That's the sum of ideas i want to implement. to go further -. what was done this code and I'm not entirely sure where to go from there. class Phonebook: def __init__(self): pass def add(self,name, number): self.name=name self.numbers=number def getName(self): return self.name def getNumber(self): return self.number def find(self, name): a = raw_input("What is their First Name?") return(self,name) def display(self): return display def main(): phone1 = Phonebook("foo bar", 13345444234214) phone2 = Phonebook("foo bar", 13345444234214) print(display()) if name == 'main': main() well what was done this code and I'm not entirely sure where to go from there. one question: can someone give me some hints - I've tried looking in books and tried to find out how to use the add function and, The question is: how to incorpoate find and display in the def main function. Thanks i guess that __init__(self): creates an empty list to store names and numbers def __init__(self): pass That does not do what the instructions want. Also: def getName(self): return self.name def getNumber(self): return self.number should i really use getters in python? [ Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.