C- Create the sub class UsedBook  that is derived from the super class Book and has the following instance variables, constructor, and functions: title ( String) isbn ( String) authors (String) publisher (String) edition ( int) published_year (int) price_new (double) // the price of the book if it is new age (int)  // how old the book is in years Constructor that takes all of the above variables as input parameters.  set/get functions calculate_price method // the price is calculated as  price_new * (1- 0.10*age) print function that prints all information related to the old book.   D- Create the Testing class that has the main method and does the following: aa- Use the constructor to create instance of NewBook class and name it as new. Call compute_price function. bb- Use the constructor to create instance of  usedBook class and name it used. Call compute_price function. cc- Print the related information of new and used objects using print functions. Use this following code:   class Book: def__init__(self, title, isbn, authors, publisher, edition, published_year): self.title = title self.isbn = isbn self.authors = authors self.publisher = publisher self.edition = edition self.published_year = published_year # Setters defsetTitle(self,title): self.title = title defsetIsbn(self,isbn): self.isbn = isbn   defsetAuthor(self,authors): self.authors = authors   defsetPublisher(self, publisher): self.publisher = publisher defsetEdtion(self,edition): self.edition = edition defsetPublishedYear(self, published_year): self.published_year = published_year # Getters defgetTitle(self): returnself.title defgetIsbn(self): returnself.isbn   defgetAuthor(self): returnself.authors   defgetPublisher(self): returnself.publisher defgetEdtion(self): returnself.edition defgetPublishedYear(self): returnself.published_year defprint(self): print("Title: ",self.getTitle()) print("ISBN: ",self.getIsbn()) print("Authors: ",self.getAuthor()) print("Publisher: ",self.getPublisher()) print("Edition: ",self.getEdtion()) print("Published Year: ",self.getPublishedYear()) class NewBook(Book): def__init__(self, title, isbn, authors, publisher, edition, published_year, price): super().__init__(title, isbn, authors, publisher, edition, published_year) self.price = price   defsetPrice(self,price): self.price = price defcalculate_price(self): returnself.price defprint(self): super().print() print("Price: ",self.calculate_price())

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter11: Inheritance And Composition
Section: Chapter Questions
Problem 5PE: Using classes, design an online address book to keep track of the names, addresses, phone numbers,...
icon
Related questions
Question

C- Create the sub class UsedBook  that is derived from the super class Book and has the following instance variables, constructor, and functions:

title ( String)

isbn ( String)

authors (String)

publisher (String)

edition ( int)

published_year (int)

price_new (double) // the price of the book if it is new

age (int)  // how old the book is in years

Constructor that takes all of the above variables as input parameters. 

set/get functions

calculate_price method // the price is calculated as  price_new * (1- 0.10*age)

print function that prints all information related to the old book.

 

D- Create the Testing class that has the main method and does the following:

aa- Use the constructor to create instance of NewBook class and name it as new. Call compute_price function.

bb- Use the constructor to create instance of  usedBook class and name it used. Call compute_price function.

cc- Print the related information of new and used objects using print functions.

Use this following code:

 

class Book:
def__init__(self, title, isbn, authors, publisher, edition, published_year):
self.title = title
self.isbn = isbn
self.authors = authors
self.publisher = publisher
self.edition = edition
self.published_year = published_year
# Setters
defsetTitle(self,title):
self.title = title

defsetIsbn(self,isbn):
self.isbn = isbn
 
defsetAuthor(self,authors):
self.authors = authors
 
defsetPublisher(self, publisher):
self.publisher = publisher

defsetEdtion(self,edition):
self.edition = edition

defsetPublishedYear(self, published_year):
self.published_year = published_year

# Getters
defgetTitle(self):
returnself.title

defgetIsbn(self):
returnself.isbn
 
defgetAuthor(self):
returnself.authors
 
defgetPublisher(self):
returnself.publisher

defgetEdtion(self):
returnself.edition

defgetPublishedYear(self):
returnself.published_year

defprint(self):
print("Title: ",self.getTitle())
print("ISBN: ",self.getIsbn())
print("Authors: ",self.getAuthor())
print("Publisher: ",self.getPublisher())
print("Edition: ",self.getEdtion())
print("Published Year: ",self.getPublishedYear())

class NewBook(Book):
def__init__(self, title, isbn, authors, publisher, edition, published_year, price):
super().__init__(title, isbn, authors, publisher, edition, published_year)
self.price = price
 
defsetPrice(self,price):
self.price = price

defcalculate_price(self):
returnself.price

defprint(self):
super().print()
print("Price: ",self.calculate_price())
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
Knowledge Booster
ADT and Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT