Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Task 1 This task will have you create a simple piece of software that simulates a Library. We will start by creating a ? Book

Task 1

This task will have you create a simple piece of software that simulates a Library. We will start by creating a ?Book? class, and a ?Patron? class. Once we have built those classes we can then use them as building blocks to implement our rudimentary library. ?For each task, make sure that you test your code to make sure it works before moving on to the next one.

Task 1.1

Implement a ?Book? class. The book class should have the following have ?private ?member variables for the ISBN (store as a string), title, author and whether or not the book is checked out or not.

? Write a ?constructor? that assigns values to each member variable as well as a ?default constructor? that leaves data uninitialized.

? Write ?public? methods for retrieving these data values.

? Write a ?public ?method for checking a book in and out.

? Write a ?public ?method -- ?istream& read_book(istream& is);

? We will use this function to load a single books data into a ?Book? object.

? This method will read a ?Book?s data in the following form ( Title: "Blah Blah" ) ( ISBN: ###-########## ) ( Author: Jane Doe )

?Task 1.2

Add operators for the ?Book? class. Have the ?==? operator check whether the ISBN numbers are the same for two books. Have ?!=? also compare the ISBN numbers. Have ?<<? print out the title, author, and ISBN on separate lines. ?==,? ?!=? should be class methods, and ?<<? must be a function.

Task 1.3

Create a ?Patron? class for the library. The class will contain a users name and library card number as ?private? member variables.

? Write a ?constructor? that assigns values to each member variable as well as a ?default constructor? that leaves data uninitialized.

? Write ?public? methods that access this data.

? Write a ?public ?method -- ?istream& read_patron(istream& is);

? We will use this function to load a single patrons data into a ?Patron? object.

? This method will read a ?Patron?s data in the following form

 ( Name: John Smith ) ( Number: #### ) 

Task 1.4

Create a ?Transaction ?struct that contains a ?Book? and a ?Patron? as member variables.

Task 1.5

Create a ?Library? class. It should contain vectors of ?Book?s, ?Patron?s, and ?Transaction?s. ? Write a constructor that takes two filenames as arguments

? The first filename will refer to a file containing a list of books (one per line)

? The second will refer to a file containing a list of patrons (one per line)

? The file formats will be the same as described in Tasks 1.1 and 1.3

? You should read each file and populate the ?Book? and ?Patron? vectors

methods that add ?Book?s and ?Patron?s to the library system.

? Write

? Write

the function

? If the book is already checked out, then print out an error message and exit the

function

? Otherwise, add a ?Transaction? to the system.

the function.

? Otherwise, set the ?Book?s status to be checked in.

? Dont worry about creating a ?Transaction? for this.

a method to print out each ?Transaction

? I will leave the formatting up to you.

? Just make sure you print out the relevant details for the Book/Patron

Task 1.6

Lets test out the final product in our main.

? Create a ?Library ?object constructed with ?booklist.txt? ?and? patronlist.txt

? Create a rudimentary menu using a ?while? loop and a ?switch-case? statement.

? The menu should have the following options

Add a book

Add a patron

Check out a book

Check in a book

Print out all Transactions

Quit Program

? For choices 1 through 4. Prompt the user for relevant input.

Task 2

Write a class called ?Vector? that will inherit from ?std::vector?.

? Override the ?[]? operator to check if the index is out of bounds or not

? If the index is out of bounds, ?throw? a ?out_of_range? exception.

? Demonstrate our added functionality in your ?main? with a ?try-catch? statement

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Expert Oracle9i Database Administration

Authors: Sam R. Alapati

1st Edition

1590590228, 978-1590590225

More Books

Students also viewed these Databases questions

Question

7. What decisions would you make as the city manager?

Answered: 1 week ago

Question

8. How would you explain your decisions to the city council?

Answered: 1 week ago