Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

2-4-B Book Class Diagram Prepare a Class Diagram, and Python code, for a class,

ID: 3594962 • Letter: 2

Question

2-4-B Book Class Diagram Prepare a Class Diagram, and Python code, for a class, Book, based on the group exercise. You may do this assignment as an individual or a group exercise. If you're working as a team, you might distribute the work, e.g., one student could do the Class Diagram while the other does the code (Naturally, you'll need to collaborate to be sure they agree). The Class Diagram needs to include all three parts: Name, Attributes, and Methods. You may stub out the member methods (using the pass keyword) in the code

Explanation / Answer

class Book:
author=""
name=""
bid=0
price=0
def __init__(self,title,author,book_id,price):
self.author=author
self.name=title
self.bid=book_id
self.price=price
def display_details(self):
print """
Book Name : %s
Book Author : %s
Book ID : %s
Book Price : Rs %s/- """ % (self.name,self.author,self.bid,self.price)
def compare(self,other):
if (self.name==other.name) and (self.author==self.author):
print "Both Books are same"

b=Book('Rich Dad Poor Dad','Robert Kowaski',1,1000)
print "Display Book Details"
b.display_details()
c=Book('Rich Dad Poor Dad','Robert Kowaski',1,1000)
print "Display Book Details"
c.display_details()
print "Compare two books"
b.compare(c)

Output:

Display Book Details

Book Name : Rich Dad Poor Dad
Book Author : Robert Kowaski
Book ID : 1
Book Price : Rs 1000/-

Display Book Details

Book Name : Rich Dad Poor Dad
Book Author : Robert Kowaski
Book ID : 1
Book Price : Rs 1000/-

Compare two books
Both Books are same

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote