Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

Group 01 Textbook

Views: 238
Kernel: SageMath (stable)

Group 1 Members

  • James MacDonald

  • Richard Tulloch

  • Morsaleen Faizee

  • Richard Panchan

G1-Textbook

This is group number 1. This entails our class Textbook with attributes -Title, Author, Publisher, Subject and ISBN #

# Program G01-Textbook class Textbook: pass # Test the class: book = Textbook() print('1st object', book)
('1st object', <__main__.Textbook instance at 0x7f1941b1cd40>)

G1-Textbook-v01

V01 defines the class, Textbook with one attribute and two methods. It instantiates two objects.

# Program G01-Textbook-v01 # Define the class: Textbook class Textbook: def __init__(self, bookTitle = 'None'): self.bookTitle = bookTitle def displayTextbook(self): print('The textbook title is: ', self.bookTitle) # Test the class: Textbook bk1 = Textbook() bk1.displayTextbook() bk2 = Textbook('Intro to Programming Logic OOA') bk2.displayTextbook()
('The object with the title ', 'Intro to Programming Logic OOA', 'author ', 'Dr. Alireza Fazelpour', 'publisher ', 'McGraw-Hill Education', 'subject of ', 'Computer Science', 'and ISBN number of ', '978-1-307-33726-6', 'was destoryed.') ('The textbook title is: ', 'None') ('The object with the title ', 'Intro to Programming Logic OOA', 'author ', 'No Author', 'publisher ', 'No Publisher', 'subject of ', 'No Subject', 'and ISBN number of ', 'None', 'was destoryed.') ('The textbook title is: ', 'Intro to Programming Logic OOA')
Exception AttributeError: "class Textbook has no attribute 'bookCountDeleted'" in <bound method Textbook.__del__ of <__main__.Textbook instance at 0x7f1941a926c8>> ignored Exception AttributeError: "class Textbook has no attribute 'bookCountDeleted'" in <bound method Textbook.__del__ of <__main__.Textbook instance at 0x7f1941e77ef0>> ignored

G1-Textbook-v02

V02 introduces an additional method totalling three methods.

# Program G01-Textbook-v02 class Textbook: def __init__(self, bookTitle = 'No Title'): self.bookTitle = bookTitle def __del__(self): print('The object with the title of', self.bookTitle, 'was destroyed.') def displayTextbook(self): print('The textbook title: ', self.bookTitle) bk1 = Textbook() bk1.displayTextbook() bk2 = Textbook('Intro to Programming Logic OOA') bk2.displayTextbook() bk1.__del__() bk2.__del__()
('The textbook title: ', 'No Title') ('The textbook title: ', 'Intro to Programming Logic OOA') ('The object with the title of', 'No Title', 'was destroyed.') ('The object with the title of', 'Intro to Programming Logic OOA', 'was destroyed.')

G1-Textbook-v03

V03 introduces two additional methods totalling five. The getter and setter method is used to change the original value of the attribute.

# G01-Textbook-v03 class Textbook: def __init__(self, bookTitle = 'No Title'): self.bookTitle = bookTitle def __del__(self): print('The object with the title of', self.bookTitle, 'was destroyed.') def getBookTitle(self): return self.bookTitle def setBookTitle(self, bookTitle): self.bookTitle = bookTitle def displayTextbook(self): print('The textbook title: ', self.bookTitle) bk1 = Textbook() bk1.displayTextbook() bk2 = Textbook('Intro to Programming Logic OOA') bk2.displayTextbook() print('\nUsing the accessor method (BEFORE using mutator method) \ for the object bk1 - the value of bookTitle = ', bk1.getBookTitle()) print('\nUsing mutator method for the object bk1 - \ to change the value of bookTitle attribute from ', \ bk1.setBookTitle('Intro to Programming Logic OOA'), 'to another value ') print('\nUsing accessor method (AFTER using mutator method) \ for the object bk1 - the new value of bookTitle = ', bk1.getBookTitle()) bk1.__del__() bk2.__del__()
('The object with the title of', 'No Title', 'was destroyed.') ('The textbook title: ', 'No Title') ('The object with the title of', 'Intro to Programming Logic OOA', 'was destroyed.') ('The textbook title: ', 'Intro to Programming Logic OOA') ('\nUsing the accessor method (BEFORE using mutator method) for the object bk1 - the value of bookTitle = ', 'No Title') ('\nUsing mutator method for the object bk1 - to change the value of bookTitle attribute from ', None, 'to another value ') ('\nUsing accessor method (AFTER using mutator method) for the object bk1 - the new value of bookTitle = ', 'Intro to Programming Logic OOA') ('The object with the title of', 'Intro to Programming Logic OOA', 'was destroyed.') ('The object with the title of', 'Intro to Programming Logic OOA', 'was destroyed.')

G1-Textbook-v04

V04 introduces an additional atrribute, totalling two, which leads to two new methods (the getter and the setter per attribute) totalling seven. It also instantiates a new object totalling three.

# G01-Textbook-v04 class Textbook: def __init__(self, bookTitle = 'No Title', bookAuthor = 'No Author'): self.bookTitle = bookTitle self.bookAuthor = bookAuthor def __del__(self): print('The object with the title of', self.bookTitle, 'and author', self.bookAuthor, 'was destroyed.') def getBookTitle(self): return self.bookTitle def getBookAuthor(self): return self.bookAuthor def setBookTitle(self, bookTitle): self.bookTitle = bookTitle def setBookAuthor(self, bookAuthor): self.bookAuthor = bookAuthor def displayTextbook(self): print('The textbook title: ', self.bookTitle, '\t', 'Author: ', self.bookAuthor) bk1 = Textbook() bk1.displayTextbook() bk2 = Textbook('Intro to Programming Logic OOA') bk2.displayTextbook() bk3 = Textbook('Intro to Programming Logic OOA', 'Dr. Alireza Fazelpour') bk3.displayTextbook() print('\nUsing the accessor method (BEFORE using mutator method) \ for the object bk1 - the value of bookTitle = ', bk1.getBookTitle(), \ ' and the value of bookAuthor = ', bk1.getBookAuthor()) print('\nUsing mutator method for the object bk1 - \ to change the value of bookTitle attribute from ', \ bk1.setBookTitle('Intro to Programming Logic OOA'), bk1.setBookAuthor('Dr. Alireza Fazelpour'), 'to another value ') print('\nUsing accessor method (AFTER using mutator method) \ for the object bk1 - the new value of bookTitle = ', \ bk1.getBookTitle(), ' and bookAuthor = ', bk1.getBookAuthor()) bk1.__del__() bk2.__del__() bk3.__del__()
('The object with the title of', 'Intro to Programming Logic OOA', 'was destroyed.') ('The textbook title: ', 'No Title', '\t', 'Author: ', 'No Author') ('The object with the title of', 'Intro to Programming Logic OOA', 'was destroyed.') ('The textbook title: ', 'Intro to Programming Logic OOA', '\t', 'Author: ', 'No Author') ('The object with the title ', 'Intro to Programming Logic OOA', 'author ', 'Dr. Alireza Fazelpour', 'publisher ', 'No Publisher', 'subject of ', 'No Subject', 'and ISBN number of ', 'None', 'was destoryed.') ('The textbook title: ', 'Intro to Programming Logic OOA', '\t', 'Author: ', 'Dr. Alireza Fazelpour') ('\nUsing the accessor method (BEFORE using mutator method) for the object bk1 - the value of bookTitle = ', 'No Title', ' and the value of bookAuthor = ', 'No Author') ('\nUsing mutator method for the object bk1 - to change the value of bookTitle attribute from ', None, None, 'to another value ') ('\nUsing accessor method (AFTER using mutator method) for the object bk1 - the new value of bookTitle = ', 'Intro to Programming Logic OOA', ' and bookAuthor = ', 'Dr. Alireza Fazelpour') ('The object with the title of', 'Intro to Programming Logic OOA', 'and author', 'Dr. Alireza Fazelpour', 'was destroyed.') ('The object with the title of', 'Intro to Programming Logic OOA', 'and author', 'No Author', 'was destroyed.') ('The object with the title of', 'Intro to Programming Logic OOA', 'and author', 'Dr. Alireza Fazelpour', 'was destroyed.')
Exception AttributeError: "class Textbook has no attribute 'bookCountDeleted'" in <bound method Textbook.__del__ of <__main__.Textbook instance at 0x7f1941b26200>> ignored

G1-Textbook-v05

V05 introduces two new methods (a getter and a setter) along with one new attribute.

# G01-Textbook-v05 class Textbook: def __init__(self, bookTitle = 'No Title', bookAuthor = 'No Author', bookPublisher = 'No Publisher'): self.bookTitle = bookTitle self.bookAuthor = bookAuthor self.bookPublisher = bookPublisher def __del__(self): print('The object with the title of', self.bookTitle, 'was destroyed.') def getBookTitle(self): return self.bookTitle def getBookAuthor(self): return self.bookAuthor def getBookPublisher(self): return self.bookPublisher def setBookTitle(self, bookTitle): self.bookTitle = bookTitle def setBookAuthor(self, bookAuthor): self.bookAuthor = bookAuthor def setBookPublisher(self, bookPublisher): self.bookPublisher = bookPublisher def displayTextbook(self): print('The textbook title: ', self.bookTitle, '\t', 'Author: ' \ , self.bookAuthor, '\t', 'Publisher: ', self.bookPublisher) bk1 = Textbook() bk1.displayTextbook() bk2 = Textbook('Intro to Programming Logic OOA') bk2.displayTextbook() bk3 = Textbook('Intro to Programming Logic OOA', 'Dr. Alireza Fazelpour') bk3.displayTextbook() bk4 = Textbook('Intro to Programming Logic OOA', 'Dr. Alireza Fazelpour', 'McGraw-Hill Education') bk4.displayTextbook() print('\nUsing the accessor method (BEFORE using mutator method) \ for the object bk1 - the value of bookTitle = ', bk1.getBookTitle(), \ ' and the value of bookAuthor = ', bk1.getBookAuthor() \ , ' and the value of bookPublisher = ', bk1.getBookPublisher()) print('\nUsing mutator method for the object bk1 - \ to change the values of bookTitle, bookAuthor, and bookPublisher attributes from ' \ , bk1.setBookTitle('Intro to Programming Logic OOA'), bk1.setBookAuthor('Dr. Alireza Fazelpour') \ , bk1.setBookPublisher('McGraw-Hill Education'), 'to other values ') print('\nUsing accessor method (AFTER using mutator method) \ for the object bk1 - the new values of \nbookTitle = ' \ , bk1.getBookTitle(), ' \nbookAuthor = ', bk1.getBookAuthor() \ , '\nbookPublisher = ', bk1.getBookPublisher()) print('\n') bk1.__del__() bk2.__del__() bk3.__del__() bk4.__del__()
('The object with the title of', 'Intro to Programming Logic OOA', 'and author', 'Dr. Alireza Fazelpour', 'was destroyed.') ('The textbook title: ', 'No Title', '\t', 'Author: ', 'No Author', '\t', 'Publisher: ', 'No Publisher') ('The object with the title of', 'Intro to Programming Logic OOA', 'and author', 'No Author', 'was destroyed.') ('The textbook title: ', 'Intro to Programming Logic OOA', '\t', 'Author: ', 'No Author', '\t', 'Publisher: ', 'No Publisher') ('The object with the title of', 'Intro to Programming Logic OOA', 'and author', 'Dr. Alireza Fazelpour', 'was destroyed.') ('The textbook title: ', 'Intro to Programming Logic OOA', '\t', 'Author: ', 'Dr. Alireza Fazelpour', '\t', 'Publisher: ', 'No Publisher') ('The object with the title ', 'Intro to Programming Logic OOA', 'author ', 'Dr. Alireza Fazelpour', 'publisher ', 'McGraw-Hill Education', 'subject of ', 'No Subject', 'and ISBN number of ', 'None', 'was destoryed.') ('The textbook title: ', 'Intro to Programming Logic OOA', '\t', 'Author: ', 'Dr. Alireza Fazelpour', '\t', 'Publisher: ', 'McGraw-Hill Education') ('\nUsing the accessor method (BEFORE using mutator method) for the object bk1 - the value of bookTitle = ', 'No Title', ' and the value of bookAuthor = ', 'No Author', ' and the value of bookPublisher = ', 'No Publisher') ('\nUsing mutator method for the object bk1 - to change the values of bookTitle, bookAuthor, and bookPublisher attributes from ', None, None, None, 'to other values ') ('\nUsing accessor method (AFTER using mutator method) for the object bk1 - the new values of \nbookTitle = ', 'Intro to Programming Logic OOA', ' \nbookAuthor = ', 'Dr. Alireza Fazelpour', '\nbookPublisher = ', 'McGraw-Hill Education') ('The object with the title of', 'Intro to Programming Logic OOA', 'was destroyed.') ('The object with the title of', 'Intro to Programming Logic OOA', 'was destroyed.') ('The object with the title of', 'Intro to Programming Logic OOA', 'was destroyed.') ('The object with the title of', 'Intro to Programming Logic OOA', 'was destroyed.')
Exception AttributeError: "class Textbook has no attribute 'bookCountDeleted'" in <bound method Textbook.__del__ of <__main__.Textbook instance at 0x7f1941b1ca28>> ignored

G1-Textbook-v06

# G01-Textbook-v06 class Textbook: bookCountAdded = 0 bookCountDeleted = 0 def __init__(self, bookTitle = 'No Title', bookAuthor = 'No Author', bookPublisher = 'No Publisher', bookSubject = 'No Subject'): self.bookTitle = bookTitle self.bookAuthor = bookAuthor self.bookPublisher = bookPublisher self.bookSubject = bookSubject Textbook.bookCountAdded += 1 print('The total # of object(s) instantiated: ', Textbook.bookCountAdded) def __del__(self): print('The object with the title ', self.bookTitle \ , 'author ', self.bookAuthor \ , 'publisher ', self.bookPublisher \ , 'and subject of ', self.bookSubject, 'was destoryed.') Textbook.bookCountDeleted += 1 print('The total # of object(s) deleted: ', Textbook.bookCountDeleted) def getBookTitle(self): return self.bookTitle def getBookAuthor(self): return self.bookAuthor def getBookPublisher(self): return self.bookPublisher def getBookSubject(self): return self.bookSubject def setBookTitle(self, bookTitle): self.bookTitle = bookTitle def setBookAuthor(self, bookAuthor): self.bookAuthor = bookAuthor def setBookPublisher(self, bookPublisher): self.bookPublisher = bookPublisher def setBookSubject(self, bookSubject): self.bookSubject = bookSubject def displayTextbook(self): print('The textbook title is: ', self.bookTitle, '\t' \ , 'Author: ', self.bookAuthor, '\t' \ , 'Publisher: ', self.bookPublisher, '\t' \ , 'Subject: ', self.bookSubject) bk1 = Textbook() bk1.displayTextbook() bk2 = Textbook('Intro to Programming Logic OOA') bk2.displayTextbook() bk3 = Textbook('Intro to Programming Logic OOA', 'Dr. Alireza Fazelpour') bk3.displayTextbook() bk4 = Textbook('Intro to Programming Logic OOA', 'Dr. Alireza Fazelpour', 'McGraw-Hill Education') bk4.displayTextbook() bk5 = Textbook('Intro to Programming Logic OOA', 'Dr. Alireza Fazelpour', 'McGraw-Hill Education', 'Computer Science') bk5.displayTextbook() print('\nUsing the accessor method (BEFORE using mutator method) \ for the object bk1 - the value of bookTitle = ', bk1.getBookTitle() \ , ' and the value of bookAuthor = ', bk1.getBookAuthor() \ , ' and the value of bookPublisher = ', bk1.getBookPublisher() \ , 'the value of bookSubject = ', bk1.getBookSubject()) print('\nUsing mutator method for the object bk1 - \ to change the values of bookTitle, bookAuthor, bookPublisher, and bookSubject attributes from ' \ , bk1.setBookTitle('Intro to Programming Logic OOA') \ , bk1.setBookAuthor('Dr. Alireza Fazelpour') \ , bk1.setBookPublisher('McGraw-Hill Education') \ , bk1.setBookSubject('Computer Science'), 'to other values ') print('\nUsing accessor method (AFTER using mutator method) \ for the object bk1 - the new values of \nbookTitle = ' \ , bk1.getBookTitle() \ , '\nbookAuthor = ', bk1.getBookAuthor() \ , '\nbookPublisher = ', bk1.getBookPublisher() \ , '\nbookSubject = ', bk1.getBookSubject()) print('\n') bk1.__del__() bk2.__del__() bk3.__del__() bk4.__del__() bk5.__del__()
('The total # of object(s) instantiated: ', 1) ('The object with the title of', 'Intro to Programming Logic OOA', 'was destroyed.') ('The textbook title is: ', 'No Title', '\t', 'Author: ', 'No Author', '\t', 'Publisher: ', 'No Publisher', '\t', 'Subject: ', 'No Subject') ('The total # of object(s) instantiated: ', 2) ('The object with the title of', 'Intro to Programming Logic OOA', 'was destroyed.') ('The textbook title is: ', 'Intro to Programming Logic OOA', '\t', 'Author: ', 'No Author', '\t', 'Publisher: ', 'No Publisher', '\t', 'Subject: ', 'No Subject') ('The total # of object(s) instantiated: ', 3) ('The object with the title of', 'Intro to Programming Logic OOA', 'was destroyed.') ('The textbook title is: ', 'Intro to Programming Logic OOA', '\t', 'Author: ', 'Dr. Alireza Fazelpour', '\t', 'Publisher: ', 'No Publisher', '\t', 'Subject: ', 'No Subject') ('The total # of object(s) instantiated: ', 4) ('The object with the title of', 'Intro to Programming Logic OOA', 'was destroyed.') ('The textbook title is: ', 'Intro to Programming Logic OOA', '\t', 'Author: ', 'Dr. Alireza Fazelpour', '\t', 'Publisher: ', 'McGraw-Hill Education', '\t', 'Subject: ', 'No Subject') ('The total # of object(s) instantiated: ', 5) ('The object with the title ', 'Intro to Programming Logic OOA', 'author ', 'Dr. Alireza Fazelpour', 'publisher ', 'McGraw-Hill Education', 'subject of ', 'Computer Science', 'and ISBN number of ', 'None', 'was destoryed.') ('The total # of object(s) deleted: ', 1) ('The textbook title is: ', 'Intro to Programming Logic OOA', '\t', 'Author: ', 'Dr. Alireza Fazelpour', '\t', 'Publisher: ', 'McGraw-Hill Education', '\t', 'Subject: ', 'Computer Science') ('\nUsing the accessor method (BEFORE using mutator method) for the object bk1 - the value of bookTitle = ', 'No Title', ' and the value of bookAuthor = ', 'No Author', ' and the value of bookPublisher = ', 'No Publisher', 'the value of bookSubject = ', 'No Subject') ('\nUsing mutator method for the object bk1 - to change the values of bookTitle, bookAuthor, bookPublisher, and bookSubject attributes from ', None, None, None, None, 'to other values ') ('\nUsing accessor method (AFTER using mutator method) for the object bk1 - the new values of \nbookTitle = ', 'Intro to Programming Logic OOA', '\nbookAuthor = ', 'Dr. Alireza Fazelpour', '\nbookPublisher = ', 'McGraw-Hill Education', '\nbookSubject = ', 'Computer Science') ('The object with the title ', 'Intro to Programming Logic OOA', 'author ', 'Dr. Alireza Fazelpour', 'publisher ', 'McGraw-Hill Education', 'and subject of ', 'Computer Science', 'was destoryed.') ('The total # of object(s) deleted: ', 2) ('The object with the title ', 'Intro to Programming Logic OOA', 'author ', 'No Author', 'publisher ', 'No Publisher', 'and subject of ', 'No Subject', 'was destoryed.') ('The total # of object(s) deleted: ', 3) ('The object with the title ', 'Intro to Programming Logic OOA', 'author ', 'Dr. Alireza Fazelpour', 'publisher ', 'No Publisher', 'and subject of ', 'No Subject', 'was destoryed.') ('The total # of object(s) deleted: ', 4) ('The object with the title ', 'Intro to Programming Logic OOA', 'author ', 'Dr. Alireza Fazelpour', 'publisher ', 'McGraw-Hill Education', 'and subject of ', 'No Subject', 'was destoryed.') ('The total # of object(s) deleted: ', 5) ('The object with the title ', 'Intro to Programming Logic OOA', 'author ', 'Dr. Alireza Fazelpour', 'publisher ', 'McGraw-Hill Education', 'and subject of ', 'Computer Science', 'was destoryed.') ('The total # of object(s) deleted: ', 6)

G1-Textbook-v07

This is the finished product. V07 includes all of the attributes and methods needed to print the proper information. Along with all the proper destructors and even a counter for added and deleted attributes.

# G01-Textbook-v07 class Textbook: bookCountAdded = 0 bookCountDeleted = 0 def __init__(self, bookTitle = 'No Title', bookAuthor = 'No Author', bookPublisher = 'No Publisher', bookSubject = 'No Subject', bookISBNNum = 'None'): self.bookTitle = bookTitle self.bookAuthor = bookAuthor self.bookPublisher = bookPublisher self.bookSubject = bookSubject self.bookISBNNum = bookISBNNum Textbook.bookCountAdded += 1 print('The total # of object(s) instantiated: ', Textbook.bookCountAdded) def __del__(self): print('The object with the title ', self.bookTitle \ , 'author ', self.bookAuthor \ , 'publisher ', self.bookPublisher \ , 'subject of ', self.bookSubject \ , 'and ISBN number of ', self.bookISBNNum, 'was destoryed.') Textbook.bookCountDeleted += 1 print('The total # of object(s) deleted: ', Textbook.bookCountDeleted) def getBookTitle(self): return self.bookTitle def getBookAuthor(self): return self.bookAuthor def getBookPublisher(self): return self.bookPublisher def getBookSubject(self): return self.bookSubject def getBookISBNNum(self): return self.bookISBNNum def setBookTitle(self, bookTitle): self.bookTitle = bookTitle def setBookAuthor(self, bookAuthor): self.bookAuthor = bookAuthor def setBookPublisher(self, bookPublisher): self.bookPublisher = bookPublisher def setBookSubject(self, bookSubject): self.bookSubject = bookSubject def setBookISBNNum(self, bookISBNNum): self.bookISBNNum = bookISBNNum def displayTextbook(self): print('The textbook title is: ', self.bookTitle, '\t' \ , 'Author: ', self.bookAuthor, '\t' \ , 'Publisher: ', self.bookPublisher, '\t' \ , 'Subject: ', self.bookSubject, '\t' \ , 'ISBN: ', self.bookISBNNum) bk1 = Textbook() bk1.displayTextbook() bk2 = Textbook('Intro to Programming Logic OOA') bk2.displayTextbook() bk3 = Textbook('Intro to Programming Logic OOA', 'Dr. Alireza Fazelpour') bk3.displayTextbook() bk4 = Textbook('Intro to Programming Logic OOA', 'Dr. Alireza Fazelpour', 'McGraw-Hill Education') bk4.displayTextbook() bk5 = Textbook('Intro to Programming Logic OOA', 'Dr. Alireza Fazelpour', 'McGraw-Hill Education', 'Computer Science') bk5.displayTextbook() bk6 = Textbook('Intro to Programming Logic OOA', 'Dr. Alireza Fazelpour', 'McGraw-Hill Education', 'Computer Science', '978-1-307-33726-6') bk6.displayTextbook() print('\nUsing the accessor method (BEFORE using mutator method) \ for the object bk1 - the value of bookTitle = ', bk1.getBookTitle() \ , ' and the value of bookAuthor = ', bk1.getBookAuthor() \ , ' and the value of bookPublisher = ', bk1.getBookPublisher() \ , ' the value of bookSubject = ', bk1.getBookSubject() \ , ' the value of bookISBNNum = ', bk1.getBookISBNNum()) print('\nUsing mutator method for the object bk1 - \ to change the values of bookTitle, bookAuthor, bookPublisher, and bookSubject attributes from ' \ , bk1.setBookTitle('Intro to Programming Logic OOA') \ , bk1.setBookAuthor('Dr. Alireza Fazelpour') \ , bk1.setBookPublisher('McGraw-Hill Education') \ , bk1.setBookSubject('Computer Science') \ , bk1.setBookISBNNum('978-1-307-33726-6'), 'to other values ') print('\nUsing accessor method (AFTER using mutator method) \ for the object bk1 - the new values of \nbookTitle = ' \ , bk1.getBookTitle() \ , '\nbookAuthor = ', bk1.getBookAuthor() \ , '\nbookPublisher = ', bk1.getBookPublisher() \ , '\nbookSubject = ', bk1.getBookSubject() \ , '\nbookISBNNum = ', bk1.getBookISBNNum()) print('\n') bk1.__del__() bk2.__del__() bk3.__del__() bk4.__del__() bk5.__del__() bk6.__del__()
('The total # of object(s) instantiated: ', 1) ('The object with the title ', 'Intro to Programming Logic OOA', 'author ', 'Dr. Alireza Fazelpour', 'publisher ', 'McGraw-Hill Education', 'and subject of ', 'Computer Science', 'was destoryed.') ('The total # of object(s) deleted: ', 1) ('The textbook title is: ', 'No Title', '\t', 'Author: ', 'No Author', '\t', 'Publisher: ', 'No Publisher', '\t', 'Subject: ', 'No Subject', '\t', 'ISBN: ', 'None') ('The total # of object(s) instantiated: ', 2) ('The object with the title ', 'Intro to Programming Logic OOA', 'author ', 'No Author', 'publisher ', 'No Publisher', 'and subject of ', 'No Subject', 'was destoryed.') ('The total # of object(s) deleted: ', 2) ('The textbook title is: ', 'Intro to Programming Logic OOA', '\t', 'Author: ', 'No Author', '\t', 'Publisher: ', 'No Publisher', '\t', 'Subject: ', 'No Subject', '\t', 'ISBN: ', 'None') ('The total # of object(s) instantiated: ', 3) ('The object with the title ', 'Intro to Programming Logic OOA', 'author ', 'Dr. Alireza Fazelpour', 'publisher ', 'No Publisher', 'and subject of ', 'No Subject', 'was destoryed.') ('The total # of object(s) deleted: ', 3) ('The textbook title is: ', 'Intro to Programming Logic OOA', '\t', 'Author: ', 'Dr. Alireza Fazelpour', '\t', 'Publisher: ', 'No Publisher', '\t', 'Subject: ', 'No Subject', '\t', 'ISBN: ', 'None') ('The total # of object(s) instantiated: ', 4) ('The object with the title ', 'Intro to Programming Logic OOA', 'author ', 'Dr. Alireza Fazelpour', 'publisher ', 'McGraw-Hill Education', 'and subject of ', 'No Subject', 'was destoryed.') ('The total # of object(s) deleted: ', 4) ('The textbook title is: ', 'Intro to Programming Logic OOA', '\t', 'Author: ', 'Dr. Alireza Fazelpour', '\t', 'Publisher: ', 'McGraw-Hill Education', '\t', 'Subject: ', 'No Subject', '\t', 'ISBN: ', 'None') ('The total # of object(s) instantiated: ', 5) ('The object with the title ', 'Intro to Programming Logic OOA', 'author ', 'Dr. Alireza Fazelpour', 'publisher ', 'McGraw-Hill Education', 'and subject of ', 'Computer Science', 'was destoryed.') ('The total # of object(s) deleted: ', 5) ('The textbook title is: ', 'Intro to Programming Logic OOA', '\t', 'Author: ', 'Dr. Alireza Fazelpour', '\t', 'Publisher: ', 'McGraw-Hill Education', '\t', 'Subject: ', 'Computer Science', '\t', 'ISBN: ', 'None') ('The total # of object(s) instantiated: ', 6) ('The object with the title ', 'Intro to Programming Logic OOA', 'author ', 'Dr. Alireza Fazelpour', 'publisher ', 'McGraw-Hill Education', 'subject of ', 'Computer Science', 'and ISBN number of ', '978-1-307-33726-6', 'was destoryed.') ('The total # of object(s) deleted: ', 6) ('The textbook title is: ', 'Intro to Programming Logic OOA', '\t', 'Author: ', 'Dr. Alireza Fazelpour', '\t', 'Publisher: ', 'McGraw-Hill Education', '\t', 'Subject: ', 'Computer Science', '\t', 'ISBN: ', '978-1-307-33726-6') ('\nUsing the accessor method (BEFORE using mutator method) for the object bk1 - the value of bookTitle = ', 'No Title', ' and the value of bookAuthor = ', 'No Author', ' and the value of bookPublisher = ', 'No Publisher', ' the value of bookSubject = ', 'No Subject', ' the value of bookISBNNum = ', 'None') ('\nUsing mutator method for the object bk1 - to change the values of bookTitle, bookAuthor, bookPublisher, and bookSubject attributes from ', None, None, None, None, None, 'to other values ') ('\nUsing accessor method (AFTER using mutator method) for the object bk1 - the new values of \nbookTitle = ', 'Intro to Programming Logic OOA', '\nbookAuthor = ', 'Dr. Alireza Fazelpour', '\nbookPublisher = ', 'McGraw-Hill Education', '\nbookSubject = ', 'Computer Science', '\nbookISBNNum = ', '978-1-307-33726-6') ('The object with the title ', 'Intro to Programming Logic OOA', 'author ', 'Dr. Alireza Fazelpour', 'publisher ', 'McGraw-Hill Education', 'subject of ', 'Computer Science', 'and ISBN number of ', '978-1-307-33726-6', 'was destoryed.') ('The total # of object(s) deleted: ', 7) ('The object with the title ', 'Intro to Programming Logic OOA', 'author ', 'No Author', 'publisher ', 'No Publisher', 'subject of ', 'No Subject', 'and ISBN number of ', 'None', 'was destoryed.') ('The total # of object(s) deleted: ', 8) ('The object with the title ', 'Intro to Programming Logic OOA', 'author ', 'Dr. Alireza Fazelpour', 'publisher ', 'No Publisher', 'subject of ', 'No Subject', 'and ISBN number of ', 'None', 'was destoryed.') ('The total # of object(s) deleted: ', 9) ('The object with the title ', 'Intro to Programming Logic OOA', 'author ', 'Dr. Alireza Fazelpour', 'publisher ', 'McGraw-Hill Education', 'subject of ', 'No Subject', 'and ISBN number of ', 'None', 'was destoryed.') ('The total # of object(s) deleted: ', 10) ('The object with the title ', 'Intro to Programming Logic OOA', 'author ', 'Dr. Alireza Fazelpour', 'publisher ', 'McGraw-Hill Education', 'subject of ', 'Computer Science', 'and ISBN number of ', 'None', 'was destoryed.') ('The total # of object(s) deleted: ', 11) ('The object with the title ', 'Intro to Programming Logic OOA', 'author ', 'Dr. Alireza Fazelpour', 'publisher ', 'McGraw-Hill Education', 'subject of ', 'Computer Science', 'and ISBN number of ', '978-1-307-33726-6', 'was destoryed.') ('The total # of object(s) deleted: ', 12)

This is the full Textbook class/module

# Textbook # This is just the Textbook class that is called upon in G01-Textbook-2 class Textbook: bookCountAdded = 0 bookCountDeleted = 0 def __init__(self, bookTitle = 'No Title', bookAuthor = 'No Author', bookPublisher = 'No Publisher', bookSubject = 'No Subject', bookISBNNum = 'None'): self.bookTitle = bookTitle self.bookAuthor = bookAuthor self.bookPublisher = bookPublisher self.bookSubject = bookSubject self.bookISBNNum = bookISBNNum Textbook.bookCountAdded += 1 print('The total # of object(s) instantiated: ', Textbook.bookCountAdded) def __del__(self): print('The object with the title ', self.bookTitle \ , 'author ', self.bookAuthor \ , 'publisher ', self.bookPublisher \ , 'subject of ', self.bookSubject \ , 'and ISBN number of ', self.bookISBNNum, 'was destoryed.') Textbook.bookCountDeleted += 1 print('The total # of object(s) deleted: ', Textbook.bookCountDeleted) def getBookTitle(self): return self.bookTitle def getBookAuthor(self): return self.bookAuthor def getBookPublisher(self): return self.bookPublisher def getBookSubject(self): return self.bookSubject def getBookISBNNum(self): return self.bookISBNNum def setBookTitle(self, bookTitle): self.bookTitle = bookTitle def setBookAuthor(self, bookAuthor): self.bookAuthor = bookAuthor def setBookPublisher(self, bookPublisher): self.bookPublisher = bookPublisher def setBookSubject(self, bookSubject): self.bookSubject = bookSubject def setBookISBNNum(self, bookISBNNum): self.bookISBNNum = bookISBNNum def displayTextbook(self): print('The textbook title is: ', self.bookTitle, '\t' \ , 'Author: ', self.bookAuthor, '\t' \ , 'Publisher: ', self.bookPublisher, '\t' \ , 'Subject: ', self.bookSubject, '\t' \ , 'ISBN: ', self.bookISBNNum)

This runs the Textbook module from above

does not actually run inside cocalc

from Textbook import * bk1 = Textbook() bk1.displayTextbook() bk2 = Textbook('Intro to Programming Logic OOA') bk2.displayTextbook() bk3 = Textbook('Intro to Programming Logic OOA', 'Dr. Alireza Fazelpour') bk3.displayTextbook() bk4 = Textbook('Intro to Programming Logic OOA', 'Dr. Alireza Fazelpour', 'McGraw-Hill Education') bk4.displayTextbook() bk5 = Textbook('Intro to Programming Logic OOA', 'Dr. Alireza Fazelpour', 'McGraw-Hill Education', 'Computer Science') bk5.displayTextbook() bk6 = Textbook('Intro to Programming Logic OOA', 'Dr. Alireza Fazelpour', 'McGraw-Hill Education', 'Computer Science', '978-1-307-33726-6') bk6.displayTextbook() print('\nUsing the accessor method (BEFORE using mutator method) \ for the object bk1 - the value of bookTitle = ', bk1.getBookTitle() \ , ' and the value of bookAuthor = ', bk1.getBookAuthor() \ , ' and the value of bookPublisher = ', bk1.getBookPublisher() \ , ' the value of bookSubject = ', bk1.getBookSubject() \ , ' the value of bookISBNNum = ', bk1.getBookISBNNum()) print('\nUsing mutator method for the object bk1 - \ to change the values of bookTitle, bookAuthor, bookPublisher, and bookSubject attributes from ' \ , bk1.setBookTitle('Intro to Programming Logic OOA') \ , bk1.setBookAuthor('Dr. Alireza Fazelpour') \ , bk1.setBookPublisher('McGraw-Hill Education') \ , bk1.setBookSubject('Computer Science') \ , bk1.setBookISBNNum('978-1-307-33726-6'), 'to other values ') print('\nUsing accessor method (AFTER using mutator method) \ for the object bk1 - the new values of \nbookTitle = ' \ , bk1.getBookTitle() \ , '\nbookAuthor = ', bk1.getBookAuthor() \ , '\nbookPublisher = ', bk1.getBookPublisher() \ , '\nbookSubject = ', bk1.getBookSubject() \ , '\nbookISBNNum = ', bk1.getBookISBNNum()) print('\n') bk1.__del__() bk2.__del__() bk3.__del__() bk4.__del__() bk5.__del__() bk6.__del__()
--------------------------------------------------------------------------- ImportError Traceback (most recent call last) <ipython-input-40-ffeae586e4b1> in <module>() ----> 1 from Textbook import * 2 3 bk1 = Textbook() 4 bk1.displayTextbook() 5 ImportError: No module named Textbook