I'm not sure if I'm heading in the right direction with this school project. I am suppose to create a 3 file, class based program that will allow you to run a very simple pizza parlor program. The menu should be displayed similar to what is shown below.
MENU
--------------------------------------------------------------------------------------------
A) What size of pizza do you want?
B) What type of toppings do you want?
C) Display/Place current order.
D) Cancel current order.
E) Quit program.
I've only attempted to complete the first 2 menu items. Can anyone tell me if I'm heading in the right direction. I have 3 days before I need to finish this so any suggestions would be greatly appreciated. Here's the code I have so far:
Thank you for any help that can be offered. Would like to know if I'm heading in the right direction. I'm not posting my code in hopes of someone completing it, but rather to see if I'm heading at this the correct way. Thank you for you time in advance.
-Roger
MENU
--------------------------------------------------------------------------------------------
A) What size of pizza do you want?
B) What type of toppings do you want?
C) Display/Place current order.
D) Cancel current order.
E) Quit program.
I've only attempted to complete the first 2 menu items. Can anyone tell me if I'm heading in the right direction. I have 3 days before I need to finish this so any suggestions would be greatly appreciated. Here's the code I have so far:
Code:
// "Pizza.h"
// Specification file for Pizza class
#ifndef PIZZA_H
#define PIZZA_H
class Pizza
{
private:
int pizzaSize;
int pizzaTop;
public:
void setPizzaSize(int);
void setPizzaTop(int);
int getPizzaSize() const;
int getPizzaTop() const;
};
#endif
// "Pizza.cpp"
// Implementation file for Pizza class
#include "Pizza.h"
#include <iostream>
using namespace std;
// setPizzaSize sets default value of ordered pizza
void Pizza::setPizzaSize(int p)
{pizzaSize = p;}
// setPizzaTop sets topping default value of ordered pizza
void Pizza::setPizzaTop(int t)
{pizzaTop = t;}
// getPizzaSize returns value in the member variable pizzaSize
int Pizza::getPizzaSize() const
{return pizzaSize;}
// getPizzaTop returns value in the member variable pizzaTop
int Pizza::pizzaTop() const
{return pizzaTop;}
// "Pizza_Program.cpp"
// Program simulates a simple pizza parlor menu ordering system
#include "Pizza.h"
#include <iostream>
#include <iomanip>
using namespace std;
// Function prototypes
void displayMenu();
void size(Pizza &);
void topping(Pizza &);
int main()
{
Pizza dinner; // Instance of pizza class object
char choice; // menu selection
cout << fixed << showpoint << setprecision(2);
do
{
// Display menu and get valid selection
diplayMenu();
cin >> choice;
while (toupper(choice) < 'A' || toupper(choice) > 'B')
{
cout << "Please make a choice from the menu below (A-B): ";
cin >> choice;
}
// Process user choice
switch(choice)
{
case 'a':
case 'A': cout << "Enter size of pizza (10,16,20,24 inches): ";
size();
break;
case 'b':
case 'B': cout << "Please enter toppings on pizza: ";
topping();
break;
}
}
while (toupper(choice) != 'C');
return 0;
}
//********************************************************
// This function displays the user's menu on the screen. *
//********************************************************
void displayMenu()
{
cout << "\n MENU\n";
cout << "--------------------------------------------------\n";
cout << "A) What size of pizza do you want?\n";
cout << "B) What type of toppings do you wants?\n";
cout << "C) Quit Program\n\n";
cout << "Enter your choice: ";
}
//********************************************************************************
// This function accepts a reference to a Pizza object. The user is asked for *
// size of pizza and the setPizzaSize member of Pizza object is called. *
//********************************************************************************
void size(Pizza &dinner)
{
int size;
cout << "
-Roger
Comment