CISC 181 Project 3
THIS CANNOT BE HANDED IN LATE
The Library's Assistant
The board of the local library has decided that computers are indeed not "just a fad", and have agreed to computerize their operations. The goal is to have all books and library cards online, and to keep track of what books are out, etc. You've been hired to design software to manage the library, its books, and its users. This project is designed to give you experience with making and using classes.
1. Program Design Requirements
To design the software, you need to think about several objects, their attributes, and what actions they can do. There are three classes (objects) in this program. book, library card, and library. Partial specifications for each of these classes are given below.
- Book- This class defines what data makes up a book object (the book object's attributes), and what actions a book object can take. The data consists of:
- Title of book
- author of book
- a ISBN (book) number
- the status: -1 - at the bindary, 0 - on the shelf, 1 - checked out
- who has the book (card id of the holder - NOT their name)
All of this data is to be private. A Book object needs to be able to initalize itself, print itself, destroy itself (destructor), copy itself (copy constructor), be assigned to (operator=), identify itself by returning its book number, get the status, set the status, get and set who has the book. No other actions are needed.
- Card- This class defines data and actions associated with a library card object. The data (attributes of a Card) consist of
- the card holder's name
- the card holders phone number
- a card id number
- the number of the book checked out (or 0, if no book)
Again, all of this data needs to be private. A Card object needs to be able to initialize itself, destroy itself, copy itself, be assigned to, return the book number, and set the book number. No other actions are necessary.
- Library- This class defines the data and actions for the library, and will contain instances of the Book, and Card classes nested in it (composition). The data for Library consists of:
- current number of cards
- current number of books
- an array of books
- an array of cards
The Library object needs to be able to initialize itself, process transactions, find a book, find a card, etc. (You'll have to fill in some of the details.) All of the library data and actions are to be private except for, the constructor, destructor, and the DoCommand function.
Suggestions: There are to be no friends in this program (Exception: you may implement operator<< for classes Book and Card). Think carefully before you write a lot of code! Think about the objects, their attributes and actions, and their public interface.
2. Main function Listing
Here is a listing of the main program - proper design generally leads to tiny mains. Studying this code will likely give you hints about how the Library object generally works.
// File: proj3.cc
// main function for library app
#include <iostream.h>
#include <fstream.h>
#include "library.h"
int main()
{
Library theLibrary( "cards.dat", "books.dat" );
char Command;
bool do_exit = false;
do
{
cout <<theLibrary.showMenu();
cin >>command;
do_exit = theLibrary.DoCommand( Command );
} while ( do_exit == false );
return 0;
}
Things you must do:
- Your library class should be able to show all library cards, show all library books, check in a book, check out a book. There should also be a menu option for exiting the program.
- Enhance the library so that new cards and books can be created. You'll have to add a couple of librarian functions, and create the user menu.
- The library should initialize itself from 2 files (one for library card data, 1 for book data) on startup, and save these config files on shutdown. (Big hint: after you overload the istream + ostream operators for Card and Book, this shouldn't be a lot of code to write. If you didn't overload these, it would be). Ultimately, how you do this is up to you. This is a large part of the project.
Grading:
- Correct Program Operation: 65%
- Test runs: 10%
- Following Good Coding Standards / Program structure: 25%
What to hand in:
- A listing of the program with appropriate comments and formatting.
- Several runs of the program, showing ALL of the programs features. This may take
several runs. That is fine.
Other Important Information:
- I hate to waste time even writing this, but all your work on the projects
MUST BE YOUR OWN. Specifically, you are NOT allowed to
work with another student, share or discuss solutions, or copy code from another student. Failure to adhere to this rule with be dealt with per University plagarism policies. Further, if you cheat on this project, the odds of you doing well on the test, and future CIS courses, are slim. Please do you own work.