Apr-10-2018, 02:24 PM
The error is because when you are trying to create your bookObj:
bookObj=book(p,t,pr,i,a)you are giving it too many arguments, but based on your init method it has only 1 argument 'self'
class book(publication): def __init__(self): publication.__init__(self)Also In your assingment it is stated, that your init() methods should initialize string member variables to empty strings and numeric values to 0, and your Book class should also have overriding populate() and display() methods which you are missing. So together with everything else I got something like this(Hopefuly you are working with python 3.6, otherwise the print statements in display() methods are not going to working for you):
class Publication: def __init__(self): self.publisher = '' self.title = '' self.price = 0 def populate(self, publisher, title, price): self.publisher = publisher self.title = title self.price = price def display(self): print(f'Publisher: {self.publisher}') print(f'Title: {self.title}') print(f'Price: R{self.price:.2f}') # formatted to display 2 decimals class Book(Publication): def __init__(self): Publication.__init__(self) self.ISBN = 0 self.authorname = '' def populate(self, publisher, title, price, ISBN, authorname): Publication.populate(self, publisher, title, price) self.ISBN = ISBN self.authorname = authorname def display(self): Publication.display(self) print(f'ISBN: {self.ISBN}') print(f'Authorname: {self.authorname}') publisher = input('Enter Publisher Name: ') title = input('Enter Title: ') price = int(input('Enter Price: ')) isbn = int(input('Enter ISBN number: ')) author = input('Enter Author Name: ') bookObj = Book() # here you create Book object -> initialise the variables either as empty string or 0 bookObj.populate(publisher, title, price, isbn, author) # here you rewrite these empty strings and 0 to values from the inputs print('The Details Of The Book Are:') bookObj.display() # and this method displays all the values