def __str__(self): print '**Entering __str__ Book method**' '''This method prints out all the information about the book, including the __str__ method from the StockItem superclass. The date is reformatted to make it more readable.''' day = str(self.dateReleased[0:2]) month = str(self.dateReleased[2:4]) year = str(self.dateReleased[4:8]) '''I call the __str__ method from superclass here. As I have overwritten the Calculate Storage Cost method of the super-class, with the special calcualteStorageCost method for books, it is the special storage costs of books that is printed out.''' print StockItem.__str__(self) print 'The book title is "%s"' %(self.title) print 'The author is %s' %(self.author) print 'The genre is %s' %(self.genre) if month == '01': month = 'January' elif month == '02': month = 'February' elif month == '03': month = 'March' elif month == '04': month = 'April' elif month == '05': month = 'May' elif month == '06': month = 'June' elif month == '07': month = 'July' elif month == '08': month = 'August' elif month == '09': month = 'September' elif month == '10': month = 'October' elif month == '11': month = 'November' elif month == '12': month = 'December' return 'The release date is %s/%s/%s' %(day, month, year)
def __str__(self): print '**Entering __str__ CD method**' '''This method prints out all the information about the CD, including the __str__ method from the StockItem superclass. The date is reformatted to make it more readable.''' day = str(self.dateReleased[0:2]) month = str(self.dateReleased[2:4]) year = str(self.dateReleased[4:8]) print StockItem.__str__(self) print 'The CD title is "%s"' %(self.title) print 'The artist is %s' %(self.artist) print 'The genre is %s' %(self.genre) if month == '01': month = 'January' elif month == '02': month = 'February' elif month == '03': month = 'March' elif month == '04': month = 'April' elif month == '05': month = 'May' elif month == '06': month = 'June' elif month == '07': month = 'July' elif month == '08': month = 'August' elif month == '09': month = 'September' elif month == '10': month = 'October' elif month == '11': month = 'November' elif month == '12': month = 'December' return 'The release date is %s/%s/%s' %(day, month, year)