Create a menu-driven program that simulates a very small library
system and meets the following requirement:
Create a class called BookType that has the following
member variables:
Variable name
Data type
Description
isbn
int
13 digit book id
title
string
Name of book
publisher
string
Name of publisher
year
int
Publishing year
rentalRate
double
employee’s pay rate
availableCopies
int
How many copies of the given book are available to
rent
The class should have the following constructors:
A default constructor that assigns the term “NA” to
all string variable and 0 to the numerical
variables.
A constructor that accepts values as arguments and assigns them
to the appropriate member variables.
Write the appropriate mutator functions (setters) that store
values in these member variables and accessor functions (getters)
that return the values of the private member variables.
Include the additional member functions listed below:
printBookInfo: the function does not take a parameter. The
function displays information about a single book as shown
below.
Title: C++ Programming: From Problem Analysis to Program
Design
ISBN: 9781337102087
Publisher: Cengage
== Available copies: 5
Note: The library only has 10 books.
Create a class called BookRent that has the following
member variables:
Variable name
Data type
Description
rentID
int
Random number between 10000 and 50000
numOfDays
int
How long the book has been rented for
rentedBoks
BookType[]
List of books rented
balance
double
Total cost of all rented books in the list
The class should have the following constructors:
A default constructor that assigns the term “NA” to
all string variable and 0 to the numerical
variables.
A constructor that accepts values as arguments and assigns them
to the appropriate member variables.
Write the appropriate mutator functions (setters) that store
values in these member variables and accessor functions (getters)
that return the values of the private member
variables.
validateRental: the member function takes the integer
parameter that represents the isbn of the book to be rented. The
function should validate that the book being rented is actually
available in the library. The function should return true if the
book is available in the library and there are enough copies,
otherwise it should return false.
printRentedList: the member function does not take a parameter.
The function displays information about all rented books as shown
below.
Title: C++ Programming: From Problem Analysis to Program
Design
ISBN: 9781337102087
Publisher: Cengage
== Rental fee: $65.78 per Semester
Title: Learning Fundamentals of Astrodynamics (Dover Books on
Aeronautical Engineering)
ISBN: 9780486838595
Publisher: Dover Publications
== Rental fee: $12.52 per Semester
Title: Computer and Information Security Handbook 2nd
Edition
ISBN: 9780123943972
Publisher: Morgan Kaufmann
== Rental fee: $45.00 per Semester
...
Note: only 6 books can be rented
In the driver function, declare a BookType array with
10 books in the library and a BookRent array object to hold 6
rented books. Prompt the user to make a selection to either view
all the books available in the library, to rent a book, and to view
their balance. Your program must implement the following driver
functions listed below.
fillLibrary: The function takes as an input file reference,
a BookType array object, and the integer size. The
function should initialize the contents of
the BookType array object accordingly. Each line of input
is laid out as follows: isbn, title, publisher, year, rental rate,
and the available copies. (Hint: you will need to use
the getline function to pull the title of the book and
publisher's name.)
printAllBooks: This function takes the BookType array
object and the integer size as parameters. The function should
print all the books in the BookType array object in the
form shown below.
menu: this function takes no parameters. The function should
display a menu of options (listed below) for the user to choose
from and prompt the user to make a choice. The function should
return the user's choice back to the calling
function.
== 1. Show all library books
== 2. Rent a book
== 3. View rental list
== 3. View bill
== 0. Quit
What would you like to do today?
viewBill: This function takes as its parameter
an BookRent array object and an integer variable for
size. The function calculates the total bill of the books
rented.
viewRental: This function takes as its parameter
a BookRent array object and an integer variable for size.
The function should display all the books rented by the user as
shown above (hint: it calls the printRentedList member
function from the BookRent object.
Create a menu-driven program that simulates a very small library system and meets the following requirement: Create a cl
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am