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 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
|
#include <string>
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
using std::string;
void updateFriendScore(int&, int);
char getResponse(string, char, char);
int getSelection(string, string);
int main()
{
int FriendScore = 0;
char response = 'Y';
string question = "";
cout << "~ Phil's Friendship Algorithm ! ~ " << endl;
cout << "Calling potential friend.." << endl;
cout << "Brrrrring....." << endl;
cout << "Brrrrring....." << endl;
cout << "Brrr...... Hello ?" << endl;
// TRY FOOD
if (getResponse("Hey ! Do you want to get some food? ", 'y', 'n') == 'Y')
{
updateFriendScore(FriendScore, getSelection("Yay! What do you prefer ?", "(1-Seafood, 2-steak, or 3-vegetarian)"));
cout << "Cool let's grub out . I'll pick you up.";
cout << " Awesome see you in a bit.. friend ;) ! " << endl;
}
else
{
//TRY SPORTS
if (getResponse("Ok no problem. Do you like sports? ", 'y', 'n') == 'Y')
{
updateFriendScore(FriendScore, getSelection("Heck Ya ! Me too ! What do you want to play ?", "(1-Basketball, 2-Baseball, 3-Football) "));
}
else
{
//TRY MOVIES
if (getResponse("Alright. I'm tired anyways. How about a movie ?!", 'y', 'n') == 'Y')
{
updateFriendScore(FriendScore, getSelection("Awesome ! What type of movie do you want to see ?", "(1-Action, 2-Suspense, 3-Romance) "));
cout << "Cool ! See you in a bit ! I'll bring the popcorn ! " << endl;
updateFriendScore(FriendScore, getSelection("Cool ! I'll bring the popcorn ! Can you bring the drinks ?", "(1-Yes, 2-Maybe, 3-No) "));
}
else
{
//TRY BEVERAGES
if (getResponse("Ya movie tickets are pretty expensive. How about we get something to drink ? Nothing expensive or tiring. What do you say ? ", 'y', 'n') == 'Y')
{
updateFriendScore(FriendScore, getSelection(" Cool lets do it. What kind of beverage do you want to get ?", "(1-Coffee, 2-Beer, 3-Tea) "));
cout << "Cool, I'll come by and pick you up. See ya in a bit ! ";
updateFriendScore(FriendScore, getSelection(" O Wait !! Before I go, I wanted to tell you not to bring any money. I'll pay since we're new friends. Is that ok ?", "(1-Yes, 2-Maybe, 3-No) "));
}
else
{
cout << "Darn. Alright well I guess I'll talk to you later. " << endl;
}
}
}
}
cout << "You scored a " << FriendScore << " ! This score represents how good of friends you will be !" << endl;
system("pause");
return 0;
}
char getResponse(string question, char positive, char negative)
{
cout << question << endl;
string prompt = "Please answer ( ";
prompt += positive;
prompt += " or ";
prompt += negative;
prompt += " ) ";
cout << prompt;
char reply = '0';
cin >> reply;
reply = toupper(reply);
while (reply != toupper(positive) && reply != toupper(negative))
{
cout << "Sheeesh @#$!! " << prompt;
cin >> reply;
reply = toupper(reply);
}
return reply;
}
int getSelection(string menu, string prompt)
{
cout << menu << endl;
cout << prompt;
int selection = 0;
cin >> selection;
while (selection < 1 || selection > 3)
{
cout << "Derrh ... !!" << prompt;
cin >> selection;
}
return selection;
}
void updateFriendScore(int ¤tTotal, int x)
{
int score = 0;
if (x == 1)
score = 10;
else if (x == 2)
score = 5;
else
score = 1;
currentTotal += score;
cout << "*** Current score is " << currentTotal << " ***" << endl;
return;
}
|