Assigned | Monday, September 14 |
Program Due | 12:00 noon, Wednesday, September 30 |
Weight | 6% |
Updates |
To gain experience:
This project is considered an OPEN project. Please review the open project policy before beginning your project.
Code from this project will be reviewed in class as noted on the schedule as "Project 1 Analysis." If you would like your code to be reviewed in class, please contact your instructor. Your name will be kept in strict confidence. This practice has worked extremely well in the past. It is a wonderful way to compare and contrast the different designs that people have used.
We all encounter cash registers when we do our shopping. Some of us have even operated a cash register as part of our job.
Your first project will be to implement a simple cash register class. You will also write a user interface (UI) class that contains main(). The UI class will be used to perform user input/output and to invoke the appropriate methods of the cash register class. The program will be driven by a simple text-based menu with 1-character menu options.
The program will simulate some basic cash register functionality. Assume, for simplicity, that a cash register can only contain bills (twenties, tens, fives, and ones). A cash register can also either be locked (it cannot be used) or unlocked (it can be used). Your store will contain exactly two such cash registers. They are referred to by number (i.e. 1 or 2).
When your program starts, it will automatically "open" your convenience store by unlocking both registers, asking the user to input the number of each of the four bill demoninations to put into each register (each register gets the same number of each bill), and putting the bills into each register. The program should ask for the number of bills in the following order: twenties, tens, fives, then ones.
Next, the following menu will be displayed.
A - Add money
R - Remove money
T - Transfer money
L - Lock register
U - Unlock register
S - Display register state
C - Close the store and quit
Further explanation of these options is as follows.
Add money - Ask the user which register (1 or 2) to add money to and then the amount to add (number of twenties, tens, fives, and ones). Add the bills to the register.
Remove money - Ask the user which register to remove money from and then the amount to remove (number of twenties, tens, fives, and ones). Remove the bills from the register.
Transfer money - Ask the user which register to transfer the money from, then the number of twenties, tens, fives, and ones to transfer. Transfer the money.
Lock register - Ask the user which register to lock, then lock the register.
Unlock register - Ask the user which register to unlock, then unlock the register.
Display register state - Ask the user which register's state to display, then display the state. A register's state consists of: whether the register is locked or unlocked, the numbers of twenties, tens, fives, and ones in the register, and the total amount of money in the register (in dollars). Display each piece of data on a separate line. Make sure to give each piece of data an appropriate label.
Close the store and quit - Close your store by removing the money from both registers, locking both registers, displaying the total amount of money (in dollars) removed from the registers (one value), and displaying the state of both registers.
Note that, where relevant, the cash register on which to perform an action (1 or 2) is specified before any other inputs needed. In general, be sure to perform the tasks listed for each command in the exact order specified above and prompt for the input needed in the exact order specified above.
proj1
.
Assuming you've used the specified file names, submit your project by typing the command
You may resubmit your files as often as you like, but only the last submittal will be graded and will be used to determine if your project is late. For more information, see the Projects page on the course web site.
More complete documentation for submit and related commands can be found here.
Remember -- if you make any change to your program, no matter how insignificant it may seem, you should recompile and retest your program before submitting it. Even the smallest typo can cause errors and a reduction in your grade.