1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
#include <iostream>
#include <cmath>
using namespace std;
class Pizza
{
private:
int anchovies =1 ;
int pepperoni =1;
int chicken=1;
int bellpepper=1;
int sauce=10;
int num;
public:
void setAnchovies(int a, int x)
{
anchovies = a;
num = x;
}
void setPepperoni(int p, int x)
{
pepperoni = p;
num = x;
}
void setChicken(int c, int x)
{
chicken = c;
num = x;
}
void setBellpepper(int b, int x)
{
bellpepper = b;
num = x;
}
void setSauce(int s, int x)
{
sauce = s;
num = x;
}
int getIngredients()
{
return anchovies * num;
return chicken * num;
return pepperoni*num;
return bellpepper*num;
return sauce*num; //10*sauce*num doesn't work either
}
};
int main()
{
int x,p=0,a=0,c=0,b=0,s=0, choice;
Pizza choice1;
cout << "How much sauce would you like?" << endl;
cin >> x;
choice1.setSauce(s, x);
cout << "That'll be "
<< choice1.getIngredients()
<< " cups of sauce." << endl;
cout << "What topping would you like?" << endl;
cout << "\n1.Pepperoni"
<< "\n2.Anchovies"
<< "\n3.Chicken"
<< "\n5.Bellpeppers" << endl;
cin >> choice;
if (choice == 1)
{
cout << "You chose Pepperoni" << endl;
cout << "How much Pepperoni would you like?" << endl;
cin >> x;
choice1.setPepperoni(p, x);
cout <<
"That'll be "
<< choice1.getIngredients()
<< " pieces of pepperoni on your pizza."
<< endl;
}
if (choice == 2)
{
cout << "You chose Anchovies" << endl;
cout << "How many anchovies would you like?" << endl;
cin >> x;
choice1.setAnchovies(a, x);
cout << "That'll be "
<< choice1.getIngredients()
<< " pieces of anchovy on your pizza." << endl;
}
system("pause");
return 0;
}
|