Arcade Gordon Freeman
Number of posts : 1727 Age : 32 Place you are be : BEHIND YOU Warnings : Registration date : 2008-01-19
Charrie Displayz lol Character: 5
| Subject: wheel of fortune Thu Apr 15, 2010 8:42 am | |
| surprisingly this isn't really as complicated as it looks - Code:
-
/* Christopher Coleman Wheel of Fortune 2nd Block */
#include <iostream> #include <string> #include <vector> #include <cmath> #include <cstdlib> #include <ctime> #include <windows.h> using namespace std;
/* Variables */
int player1score(0); string sofar; string category; string phrase; string guessedletters=""; vector<int>wheel; string name;
/* Functions */
vector<int>setup(); void print(vector<int>); void pause(); int spin(vector<int>); void welcome(); void directions(); char buyvowel(); string solve(); void categories(); char guess(); void changecategory();
/* Main */
int main() { SetConsoleTitle("Wheel of Fortune!"); system("color F0"); srand(time(0)); wheel=setup(); welcome(); cout << "The category is " << category << "\n\n"; while(true) { if (sofar==phrase) { sofar=""; changecategory(); } directions(); int choice; cin >> choice; switch(choice) { case 1: cout << "Spinning the wheel!\n"; guess(); break; case 2: buyvowel(); break; case 3: solve(); cout << endl; break; case 4: return 0; break; default: cout << "Invalid choice.\n\n"; } } } /* Functions */
void welcome() { cout << "\tWelcome to Wheel of Fortune!\n\n"; cout << "Please enter your name: "; cin >> name; }
void directions() { cout << "\tSo far, the phrase is:\n\t" << sofar << endl; cout << "\t" << name << " has " << player1score << " dollars.\n\n"; cout << "Enter 1 to spin the wheel and guess a consonant.\n"; cout << "Enter 2 to buy a vowel.\n"; cout << "Enter 3 to guess the word.\n"; cout << "Enter 4 to exit.\n"; }
void pause() { int a; cin >> a; }
vector<int>setup() { vector<int>a; a.push_back(0); for (int i=0; i <= 20; i++) { int space = (rand() % 10 + 1)*100; a.push_back(space); } a.push_back(0); int space = (rand()%11+5)*1000; if (space < 15000) space = 15000; a.push_back(space); categories(); return a; } int spin(vector<int>a) { random_shuffle ( a.begin(), a.end() ); return *a.begin(); }
void print(vector<int>a) { for (vector<int>::iterator i = a.begin(); i != a.end(); i++) cout << *i << endl; }
char buyvowel() { if (player1score < 250) cout << "You don't have enough money to buy a vowel.\n\n"; else { char a; int count(0); cout << "Enter your guess: "; cin >> a; a=tolower(a); if (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u') { player1score = player1score-250; for (int i=0; i<phrase.size(); i++) { if (phrase[i]==a) { sofar[i]=a; count++; } } if (count > 0) cout << "There are " << count << " '" << a << "'s in the phrase.\n\n"; else cout << "There are no '" << a << "'s in the phrase.\n\n"; return a; } else cout << "Why would you waste your money like that?\n\n"; } }
void changecategory() { categories(); cout << "The category is " << category << "\n\n"; }
string solve() { cout << "Enter your guess: "; string guess; cin.ignore(); getline(cin,guess); if (phrase==guess) { sofar=guess; cout << "You guessed correctly!\n"; cout << "The phrase was " << sofar << "\n"; player1score=player1score+1000; sofar=""; changecategory(); } else cout << "Sorry, that's incorrect.\n"; return guess; } char guess() { int z = spin(wheel); int count(0); cout << "You landed on " << z << "\n"; if (z != 0) { cout << "Enter your guess: "; char y; cin >> y; y=tolower(y); if (y == 'a' || y == 'e' || y == 'i' || y == 'o' || y == 'u') cout << "No free vowel for you.\n\n"; else { for (int i=0; i<phrase.size(); i++) { if (phrase[i]==y) { sofar[i]=y; count++; } } if (count > 0) { cout << "There are " << count << " '" << y << "'s in the phrase.\n\n"; player1score=player1score+(count*z); } else cout << "There are no '" << y << "'s in the phrase.\n\n"; return y; } } else { player1score=0; cout << "Whoops, you've gone bankrupt!\n\n"; } }
void categories() { vector<string>places; vector<string>famous_person; vector<string>video_games; vector<string>cartoons; int puzzle=(rand()%4)+1; places.push_back("Places"); places.push_back("tokyo"); places.push_back("hollywood"); places.push_back("bikini bottom"); places.push_back("sydney australia"); places.push_back("the himalayas"); famous_person.push_back("Famous Person"); famous_person.push_back("jack black"); famous_person.push_back("will smith"); famous_person.push_back("grandmaster flash"); famous_person.push_back("dj shadow"); famous_person.push_back("jesus"); video_games.push_back("Video Games"); video_games.push_back("sonic the hedgehog"); video_games.push_back("pokemon"); video_games.push_back("call of duty"); video_games.push_back("i want to be the guy"); video_games.push_back("god of war"); cartoons.push_back("Cartoons"); cartoons.push_back("dexters lab"); cartoons.push_back("powerpuff girls"); cartoons.push_back("ed edd n eddy"); cartoons.push_back("two stupid dogs"); cartoons.push_back("the proud family"); switch(puzzle) { case 1: category=*places.begin(); phrase=*(places.begin()+((rand()%5+1))); for (int i=0; i<phrase.size(); i++) { if (phrase[i]==' ') sofar=sofar+' '; else sofar=sofar+'-'; } break; case 2: category=*famous_person.begin(); phrase=*(famous_person.begin()+((rand()%5+1))); for (int i=0; i<phrase.size(); i++) { if (phrase[i]==' ') sofar=sofar+' '; else sofar=sofar+'-'; } break; case 3: category=*video_games.begin(); phrase=*(video_games.begin()+((rand()%5+1))); for (int i=0; i<phrase.size(); i++) { if (phrase[i]==' ') sofar=sofar+' '; else sofar=sofar+'-'; } break; case 4: category=*cartoons.begin(); phrase=*(cartoons.begin()+((rand()%5+1))); for (int i=0; i<phrase.size(); i++) { if (phrase[i]==' ') sofar=sofar+' '; else sofar=sofar+'-'; } break; } }
| |
|
Oozing Anus Gordon Freeman
Number of posts : 1530 Age : 30 Place you are be : in the middle of nowhere Warnings : Registration date : 2008-02-18
Charrie Displayz lol Character: 69
| Subject: Re: wheel of fortune Thu Apr 15, 2010 2:03 pm | |
| Is it sad I can understand most of that and convert it to English? y/y | |
|
Brosie HAAAAAAAAAAAAAX!!
Number of posts : 1018 Age : 29 Warnings : Registration date : 2008-06-11
Charrie Displayz lol Character: 5
| Subject: Re: wheel of fortune Fri Apr 16, 2010 1:56 am | |
| | |
|
Arcade Gordon Freeman
Number of posts : 1727 Age : 32 Place you are be : BEHIND YOU Warnings : Registration date : 2008-01-19
Charrie Displayz lol Character: 5
| Subject: Re: wheel of fortune Fri Apr 16, 2010 4:32 am | |
| - Ro Ro Ro Your Boat wrote:
- ....what
i actually mainly posted this to show vix what we've been doing in programming class i meant to delete it afterwards but i got lazy and since it's already here might as well just leave it | |
|
CAPRICIOUS BigBCC
Number of posts : 1524 Age : 32 Place you are be : FREEDOM Warnings : Registration date : 2008-08-13
Charrie Displayz lol Character: lffgfgfgfgdaferg
| Subject: Re: wheel of fortune Fri Apr 16, 2010 6:20 am | |
| YOU DON'T CALL YOURSELF CHRIS AT SCHOOL? | |
|
Brosie HAAAAAAAAAAAAAX!!
Number of posts : 1018 Age : 29 Warnings : Registration date : 2008-06-11
Charrie Displayz lol Character: 5
| Subject: Re: wheel of fortune Fri Apr 16, 2010 4:41 pm | |
| - Wizard Kelly wrote:
- Ro Ro Ro Your Boat wrote:
- ....what
i actually mainly posted this to show vix what we've been doing in programming class
i meant to delete it afterwards but i got lazy and since it's already here might as well just leave it Oic. ...I don't understand like...any of it. /fails | |
|
Sponsored content
| Subject: Re: wheel of fortune | |
| |
|