In this assignment you are to prepare a Visual Studio .NET application
programmed in C# that will enable the user to take
orders, change prices, add/remove products, and compute and summarize
the amount owed in orders taken in a small
business such as a fast food restaurant. The restaurant has several
entrees (main courses) that can be chosen as well as
several side orders..
The user should be able to select a from an "Entree" dropdown
combo box that includes the initial items: "Steak", "Fish",
"Spaghetti", "Roast Beef", "Pork Chops", "Shrimp", "Hamburger", and
"Hot Dog". Each of these has an initial price
of $10.75, $8.95, $5.50, $7.25, $8.75, $9.95, $3.85, and $2.00, respectively.
Each time a new entree is selected the price
should appear in a "Basic Meal Unit Price" label control. There should
also be a "Change Price" button which, when clicked,
changes the price of the currently-selected entree to that entered
by the user in a "New Price" text box. In addition there
should be a "Side Order" label control followed by several check boxes
indicating the possible side orders that can be chosen.
These are: "Potato ($0.50)", "Rice ($0.30)", "Veggie ($0.40)", "Dessert
($1.00)", "Salad ($0.60)", "Beverage ($0.80)", and
"Coffee ($0.75)". All of the above-mentioned controls should be contained
in a "Select Meal "group box.
There should also be an "Order Information" group box that contains
a "Quantity" text box, a "Calculate Selection" button, and
an "Item Amount" label control. The user may enter a number in the
"Quantity" text box to indicate how many orders of the
currently-selected entree and side orders he/she wants to order. Clicking
the "Calculate Selection" button will add that item to
the purchase and cause the price of that order of the selected meal
to be displayed in the "Item Amount" label control. In
addition, outside the "Order Information" group box there should be
a "Total Due" label control that is updated to display a
running total of the total price of that order every time a new item
is added to it.
Underneath the "Order Information" group box there should be two buttons.
One should be a "New Meal" button which allows
the user to begin to order a new set of meals. The second button should
be a "Summary" buttons which, when clicked, will display
a message box giving the total number of orders placed to date, the
total sales value of all the orders, and the average sale value
of those orders.
Underneath the "Select Meal" group box there should be two buttons:
"Add an Entree" and "Remove an Entree". The first of
those buttons should cause a modal dialog box to be displayed which
will allow the user to add a new entree and its price to the
meals sold by the restaurant. The second should cause the currently-selected
entree to be deleted from the meals sold by the
restaurant.
Finally there should be an "Exit" button that, when clicked, closes
the application. The following figure shows the kind of window
that should be visible as the application is executing.
The figure below shows what the dialog box that appears should look like when the "Add an Entree" button is clicked:
Some hints:
The combo box that is used to hold the meal entrees is itself an adequate
data structure to store, add to, and remove flavors.
However you will also need an additional dynamic data structure to
store their prices. My suggestion is to use an ArrayList that
is parallel to the combo box's Items property list. The ArrayList that
I used stored values of type decimal -- which means that
any time you assign a literal value to any variable or other data structure,
you must use the "M" suffix on the literal (e.g., 1.50M).
Any time a new entree is added to or removed from the combo box, your
code should add or remove the corresponding
decimal price to or from the ArrayList.
The dialog box that is invoked whenever the user wants to add a meal
entree and price will, of course, be encapsulated in a
separate class derived from Form. That dialog box should be invoked
modally, and the input provided by the user should only be
used if the user clicks the OK button; nothing should happen if he/she
clicks the Cancel button. Any values that are to be retrieved
by the parent form should be available as public properties of that
dialog box's class.
You will need class level variables in your Form class to keep track
of the total amount due for a given order as different quantities
of different meals are selected by the user and to keep track of the total
number of orders placed to date and the total sales value
of those orders.
Any time any dollar amount is displayed in a text box or any other control
it should be formatted approriately. You could use the
variable's ToString("C") member method to do that formatting.
Ideally your program should have try/catch exception blocks that put
up error message boxes whenever invalid data is input by the
user. However, please leave that for last. It is much more important
to get all the desired functionality first.