求做c++大作业
要求
CP1300 Assignment 1: Street Snacks
Problem Description
There are many places to eat in Beijing. Popular meals are Jiānbĭng guŏzi, yángròu
chuan, and bīngtáng húlu. For a tourist visiting Beijing, it might be very useful to
know where to find snack carts. Knowing other things would also be very useful,
like which snack cart has the best Jiānbĭng guŏzi.
Your Task:
1. Based on the example program provided called EgStreetSnacks.cpp, design a
SnackCart class and a Meal class. Review the functionality of the example program
to determine which parts should be made into member functions of the SnackCart
class and the Meal class. The class declarations need to be stored in SnackCart.h
and Meal.h, and the member function definitions (implementation) in SnackCart.cpp
and Meal.cpp.
2. Write a program MealTest.cpp that performs unit tests on the Meal class to help you
verify that it works correctly. The program needs to be commented to explain what
each unit test is trying to verify.
3. Write a program CartTest.cpp that performs unit tests on the SnackCart class to
help you verify that it works correctly. The program needs to be commented to
explain what each unit test is trying to verify.
4. Rewrite the example program StreetSnacks.cpp so that it makes use of the
SnackCart class and the Meal class.
5. Add functionality to your new program so that each SnackCart can offer one or more
meals, and it can record the name of the cart owner. Currently, the example program
just records the snack cart location and only allows one meal per snack cart.
6. When displaying snack cart information in the new program, show the owner’s name,
location, and the number of meals offered.
7. Add functionality to the new program so that the user can display the cheapest meal
and the best meal for each snack cart. The best meal is one that has the highest
rating at the lowest cost.
General Functionality (some of this is already in the code given):
• The program should be able to handle invalid inputs and display error messages
where appropriate, in particular: invalid meal cost (float) or invalid meal rating
(string). It does not need to handle users entering characters instead of numbers.
• Your program code should use looping and functions/methods where appropriate.
• You are to use a single array of objects for the data, use a constant maximum of
5 snack carts. Each snack cart should have a constant maximum of 5 possible
meals.
• You can assume that the input file exists and is accessible. You can also assume
that the data will be in the correct format within the file.
• Good code formatting is expected. You are to use constants to define any fixed
values. All code files must use descriptive variable names and include
appropriate commenting, including a descriptive header at the top of the file
(including at least your name, date and description).
• Match the sample program’s output (for new functionality use similar formatting
and wording). Use $ signs in your output where appropriate. Prices are fractional
(dollars and cents).
Submission
Your code must compile and run cleanly on a Unix machine using g++. It must be able
to read and write files using the format as seen in the file “carts.txt”, not some other file
format.
You are to submit a single zip file with all and only the following files (no sub-folders):
Meal.h Meal class declaration
Meal.cpp Meal member function definitions
SnackCart.h SnackCart class declaration
SnackCart.cpp SnackCart member function definitions
MealTest.cpp unit tests for the Meal class
CartTest.cpp unit tests for the SnackCart class
StreetSnacks.cpp the street snacks database program
makefile a makefile to compile the programs: MealTest, CartTest,
and StreetSnacks
carts.txt text file containing the data records from running the
StreetSnacks program
The assignment is to be submitted in LearnJCU. It is expected that your files have
sufficient comments so that no other documentation is needed to understand the code.
Please note: when you upload the zip file you may get an error message. IGNORE IT. LearnJCU
submission box performs plagiarism detection which will not work on zip files – the error message means
your upload has worked but the plagiarism detection has not.
附有提示的源代码 会的加我q 870604843 我把作业压缩吧发过去