Description
Purposes: This project will give you experience using stacks, queues in STL.
Descriptions:
A summer camp has three groups of students at the University X. Each group is symbolized by a
color: red, green and blue. The students have their lunches at the university’s cafeteria by
following a single line at the cafeteria’s gate. At the gate, there are two stacks of trays and each
tray is one of the three colors used by the groups. The cafeteria has 20 trays of each color,
randomly distributed in the two stacks.
The students have a lot of group spirit: they will only use trays that are one of their group colors.
For example, a student of the red group will only eat from a red tray. So, a student will keep
popping trays off their chosen stack (randomly) to get to a red tray, pushing the rejects onto the
other stack; if he/she finds no tray of his/her appropriate color, he/she reverses the process to go
through the other stack, and if student still find no tray of the appropriate color, then the student
takes the top tray of the remaining stack.
The cafeteria serves three different entrees, two different desserts, and salad. The entrees are:
chicken ($4.75), fishsticks ($4.00) or meatless lasagna ($3.75). The desserts are: cheesecake
($2.50) or pudding ($1.25). Salad costs $1.50 per ounce.
When a student enters the cafeteria, they already know what they plan to eat: how many ounces
of salad, which entree and which dessert. Every student also has a name and a group. For
example, Kim from the red group might want 3 ounces of salad, fishsticks and pudding, while
Lee from the green group might want 6 ounces of salad, lasagna and cheesecake.
Students are not charged individually for their food. Instead, at the end of the meal, the cafeteria
adds up the cost for all students of each group, and presents each group with an itemized bill.
For this project, write a program that simulates the cafeteria. Because you now have a lot of
experience with object-oriented program design in C++, you will have considerable autonomy in
how to design the program, under these conditions:
1. The student queue must be implemented using a queue;
2. The tray stacks must be implemented using stacks;
3. The main program should be used only for inputting, outputting and controlling the
overall system.
4. Student and group should be implemented as classes. Every class should have at least
one regular constructor as well as a copy constructor.
Due to the tight schedule of this semester, to simplify the project, a template has been provided to
get you started easier. However, feel free to provide your own implementation and be creative in
implementing the simulation. If you decide to use the template, please follow the following steps:
1) get the template from https://geoteci.engr.ccny.cuny.edu/CSc212/p3template.zip.
2) unzip the file to a directory.
3) test compile the program if you are using VC++ (Visual Studio), add the C++ files to a project.
If you are using g++, using the following command line
g++ cafeteriaTest.cpp group.cpp student.cpp cafeteria.cpp.
4) read all the header files (with pre/post conditions) and the implementation files to understand
the simulation logic.
CSc 221 Sec AB Project3
5) implement the three functions that are needed for the simulation: Cafeteria::pickTray()in
cafeteria.cpp, the overloaded output operator of Group in group.cpp and Student::genPrice() in
student.cpp.
6) continue reading on this project description to see the grading policies.
A test input file is available at https://134.74.112.65/CSc212/p3.data
Input file begins with a single integer representing the seed for the random number generator:
123456789
The seed will be followed by student entries, which will have the following form:
StudentName
GroupName
#OuncesSalad
EntreeName
DessertName
For example:
Kim
red
3
Fishsticks
Pudding
The last entry in the input file will have one word:
Done
Output should have the groups listed alphabetically, and should have the following form:
Group red
Kim: $9.75
Jan: $12.25
Total: $22.00
Group blue…
Before Starting:
1. Read Chapters 7.1, 7.3, 8.1, 8.2, 8.3 and 8.5, especially the car simulation example in Chapter
8.2
2. You will need to learn how to read data from files in C++ using fstream.
3. You will also need to learn how to use srand and rand functions by yourself in order to
simulate the randomness of assigning colors to trays and choosing initial stack.
What you need to turn in through Blackboard:
1. If you are using the template, submit the three revised cpp files, i.e., student.cpp, group.cpp
and cafeteria.cpp. Otherwise, you will need to provide the complete implementation.
2. A 1-page description to describe your understanding of the simulation process and the
considerations of your designs and implementations of the three member functions.
Grading Policies:
Cafeteria::pickTray – 50%
Output operator of Group – 15%
Student::genPrice – 15%
1-page description – 20%

