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
|
#include <iostream>
#include <string>
using namespace std;
class Ingredient {
string name[6] = { "apple", "eggs", "ham", "potato", "cheese", "tuna" };
public:
Ingredient();
void getName();
string setName() { return name[6]; }
};
Ingredient::Ingredient()
{
cout << "Ingredient ";
}
void Ingredient::getName()
{
cout << ": ";
for (int i = 0; i < 6; i++)
{
cout << name[i] << " ";
}
cout << endl;
}
class Combin : public Ingredient
{
string names[15] = { "pizza", "burger", "chopstick", "fried rice", "tuna soup", "egg with rice", "Gratin", "Cheese ball", "Tuna mayo rice bowl", "Potato croquette", "sandwitch", "rice with burger", "French fries", "potato soup", "tuna Sashimi"};
public:
Combin();
string calc(string name);
};
Combin::Combin()
{
cout << "Choose two things you like : ";
}
string Combin::calc(string name)
{
string n, a;
cin >> n >> a;
for (int i = 0; i < 6; i++)
{
if (n == setName() && a == setName())
{
cout << name[i] << name[i]<< endl;
}
}
{
for (int i = 0; i < 6; i++)
{
if (name[0] && name[i + 1])
cout << names[i];
}
for (int i = 0; i < 4; i++)
{
if (name[1] && name[i + 2])
cout << names[i + 6];
}
for (int i = 0; i < 3; i++)
{
if (name[2] && name[i + 3])
cout << names[i + 10];
}
for (int i = 0; i < 2; i++)
{
if (name[3] && name[i + 4])
cout << names[i + 12];
}
if (name[4] && name[5])
cout << names[14];
}
return 0;
}
int main()
{
string d;
Ingredient i;
i.getName();
Combin c;
c.calc(d);
}
|