COSC 071: Computer Science I

Project 5
Spring 2007

Due Wed Mon, Apr 30 @ 5 PM
10 points

Last one. p5 = p3 + p4.

Use the Transaction class from p4 to implement the Bill class, which should read and store Transaction objects. It should maintain a count of the number of SMS messages, minutes for in-network calls, and minutes for out-of-network calls. The implementation should have methods that print a summary of the bill as well as the individual transactions of the bill. Bill::printSummary should duplicate your program's output from p3.

The class should let programmers add a single transaction to the bill, and should have methods for reading and writing the bill's transactions to a file given a filename. Finally, so programmers can read multiple bills, the class should provide method that "clears" the bill object by setting it to its default state.

If you wish, use the following class definition as a template, guide, or inspiration.

class Bill
{
  public:
    Bill();
    string getPlan();
    void setPlan( string newPlan );
    void add( Transaction transaction );
    void printSummary( ostream &out = cout );
    void printTransactions( ostream &out = cout );
    void writeTransactions( string filename );
    int readTransactions( string filename );
    void clear();

  private:
    string plan;
    int outNetMins;
    int inNetMins;
    int SMSMsgs;
    vector<Transaction> transactions;

    double calcInNetworkOverage();
    double calcOutOfNetworkOverage();
    double calcSMSOverage();

}; // Bill class
All of these methods must work, but main should approximate the functionality of your solution to p3. That is, main should read transactions from p5.dta, and it should print the transactions and the bill's summary to the console. The methods of the Bill class should detect and report errors using the error-handling mechanisms of the Transaction class. For this project, it is acceptable to write error messages to cout, but this occur only in main.

Hints for development. You may decide whether to declare global or class constants. Implement your project method by method, testing each thoroughly in main. Continue in this fashion until you have implemented and tested all of the methods of the Transaction class.

Instructions for Submission

At the top of the file containing your source code (i.e., the file containing the C++ instructions), place the following header comment, with the appropriate modifications:
/**
 * Project 5
 * Name: <your name>
 * E-mail: <e-mail address>
 * COSC 071, Spring 2007
 *
 * In accordance with the class policies and Georgetown's Honor Code,
 * I certify that, with the exceptions of the lecture notes and those
 * items noted below, I have neither given nor received any assistance
 * on this project.
 *
 * Description: <Describe your program>
 */

When you are ready to submit your program for grading, use the submit program. Both submit.jar and the file containing your program should be in the same directory. This assignment's label is p5, so the form of the submit command is

seva% java -jar submit.jar -a p5 -f <file>
Assuming the file you want to submit is p5.cc, then to submit you enter the command
seva% java -jar submit.jar -a p5 -f p5.cc
Make sure you submit the file containing your program's source, not its executable code; that is, do not submit a.out.

Once you've submitted your project, it is a good idea to keep a copy on seva, which preserves the modification date and time and ensures that you will have a backup copy of your project. If we lose your project or submit breaks, then we will need to look at the modification date and time of your project to ensure that you submitted it before it was due.

The TAs who will be grading your projects this semester are listed on the main page. You must submit your project before 5 PM on the due date.

Plan B

The submit program is pretty reliable, but it is software. If it is three minutes before the deadline and the submit program breaks, here's Plan B. You are to mail your program to our grading account. The syntax for this command is
seva% mail -s "<netid>.cc" cosc071@cush < <filename>
Assume that I want to submit my file named p5.cc. Then I would type
seva% mail -s "maloofm.cc" cosc071@cush < p5.cc
This command sends mail with the subject "maloofm.cc" to our grading account (cosc071@cush). The body of the e-mail is the contents of the file p5.cc. Use Plan B only if you have made sure that submit is truly broken. Finally, don't send normal mail to this account because no one will be checking it regularly.