Sorry! We could not find what you were looking for

Try going back to the main page here

 
4
4
0
0
0
0

Project 3

Library Simulation

Posted: Sunday 10/20/02
Design Document Due: before midnight, Sunday 10/27/02
Project Due: Before midnight, Sunday 11/3/02
Notes 26 Oct 2002
The sample command file contained the command PATRONBOOKS, whereas the project description lists the command as PATRONSBOOKS. As always, the project description is correct. The sample command file has been changed.
24 Oct 2002
Note that is NOT a requirement that function parameters all be pointers. You may choose whether function parameters are pointers or not.
An additional error check has been added. (See the requirements section.
23 Oct 2002
In response to student questions...
  1. You are NOT permitted to use the vector< > class (or any other class) from the Standard Template Library (STL). You are still allowed to use the string class.
  2. You may implement and use your own version(s) of the SmartArray class discussed in the text and in lecture. However, this class must initally hold a single element and double it's size when full.
  3. A command file is being provided for your testing and to show the precise format of the file. (See the command file format section below.) It should not be considered a complete test of your program. Just because your program works perfectly for this command file doesn't mean it you will get a perfect score. Students are encouraged to create their own command files and trade them with their friends. The sample command file can be copied from Mr. Frey's public directory /afs/umbc.edu/users/d/e/dennis/pub/CMSC202/p3


Objectives

To understand principles of pointer usage and their effect in objects including


Background

The use of dynamic memory allocation is a fundamental programming technique. Pointers are the only mechanism available to reference memory that is dynamically allocated. The use of dynamic memory, while an essential technique, has potential problems. This project is designed so that you gain experience with these potential problems --


Project Description

This project will simulate a simple library. The library will consist of a set of books and set of patrons (people who borrow and return books). Your program will read commands from a file to perform the following functions.
  1. Add a book to the library
  2. Add a patron to the library
  3. Check out a book to a patron
  4. Allow a patron to return (check in) a book
  5. List all books in the library
  6. List all patrons of the library
  7. List all books currently checked out to a particular patron

Project Specification

Class Design Guidelines

Your program must include the C++ classes listed below. You are free to design the classes as you see fit with the following restrictions
  1. All data in all classes must be private.
  2. You must write a default constructor, copy constructor, assignment operator and destructor for all classes, even if the default behavior provided by the compiler is sufficient (it's not) and even if they're not used.
  3. You may provide any accessors you deem necessary.
  4. All allowable member functions may be overloaded.
  5. You are free to add any appropriate constructors and any private functions you deem necessary without justification.
  6. You may provide public methods other than those described above or specified below for any class if you can provide sufficient justification in your design assignment submittal. Insufficient justification will result in point deductions.
  7. All class designs must follow basic OO principles of encapsulation and data hiding.
  8. No friends are permitted, except for the insertion operator ( operator<< ) if you choose to implement it.

Required Classes

The Library Class

The libarary class must contain the following data.
  1. A dynamically allocated array of Books. Initially, the array is allocated with enough space for one Book. The capacity of the arrray is doubled whenever the array becomes full.
  2. A dynamically allocated array of Patrons. Initially, the array is allocated with enough space for one Patron. The capacity of the arrray is doubled whenever the array becomes full.
The library class provides public methods to support the operations listed above in the
project description. There is no need for an overloaded insertion operator for this class.

The Book Class

The book class contains the title and author of the book. A book is uniquely identified by its title.

The book class must provide public methods to support the following operations

  1. check out a book
  2. return (check in) a book
An overloaded insertion operator may be provided.

The Patron Class

The Patron class contains the name of the patron.

The Patron class provides no special operations. An overloaded insertion operator may be provided.

Other Requirements and Restrictions

In addition to the coding standards, your project must adhere to the following requirements

Assumptions

You may assume the following:
  1. All dynamic memory allocations are successful.
  2. If the command file can be opened, it will be in the syntactically correct format described below.

The Command File

The command file contains command words and data for each command where appropriate. To minimize the amount of work necessary for parsing the command file, each command word and data item will be on a separate line. Blank lines may occur anywhere within the file and should be ignored. The command file contains the following command words and data items. All command words will be in UPPERCASE.
  1. ADDBOOK -- add a book to the library
    data: book's title, book's author
  2. ADDPATRON -- add a patron to the library
    data: patron's name
  3. BOOKS -- print all books in the library
    no data
  4. CHECKOUT -- check a book out of the library
    data: book's title, patron's name
  5. CHECKIN -- return a book to the library
    data: book's title
  6. PATRONSBOOKS -- list all books checked out to a patron
    data: patron's name
  7. PATRONS -- list all patrons of the library
    no data

Sample Output

There are three required outputs from this program
  1. a list of all books in the library
  2. a list of all books currently checked out to a particular patron
  3. a list of all patrons of the library

No sample output is being provided. You may format your output in any neat, easy to read format you feel is appropriate as long as the required information listed below is present. Your program must handle all situations in which there is nothing to print (i.e. no books or no patrons)

1. List of all books

This output must include the following information for each book
  1. Title
  2. Author
  3. Status - checked in or checked out
  4. If the book is checked out, the name of the patron who has borrowed the book must be shown

2. List of Books for a Patron

This output must include the following information
  1. The patron's name
  2. The title and author of each book checked out by this patron

3. List of Patrons

This output is a neatly organized list of patron names.


Project Make File

You are required to submit a make file with this project. The grader should simply need to type "make Proj3" and your project should compile and link to an executable called Proj3. The grader should also have the ability to do a "make clean" and "make cleanest."

See the CMSC 202 syllabus for links to more information on make files.


Grading

10 Points Extra Credit

For 10 points of extra credit (all or none), do all of the following WARNING -- Work on the extra credit only after you have submitted a working project that meets all required specifications.

Project Submission

You must use separate compilation for this project. You should submit the following files: Submit as follows: submit cs202 Proj3 <list of files> You can check to see what files you have submitted by typing submitls cs202 Proj3 More complete documentation for submit and related commands can be found here.

Sorry! We could not find what you were looking for

Try going back to the main page here

 
4
4
0
0
0
0