Hackers League
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Hackers League

100% 1337
 
HomeHome  PortalPortal  Latest imagesLatest images  RegisterRegister  Log inLog in  

 

 wheel of fortune

Go down 
4 posters
AuthorMessage
Arcade
Gordon Freeman
Gordon Freeman
Arcade


Male
Number of posts : 1727
Age : 32
Place you are be : BEHIND YOU
Warnings :
wheel of fortune Left_bar_bleue0 / 1000 / 100wheel of fortune Right_bar_bleue

Registration date : 2008-01-19

Charrie Displayz
lol Character: 5

wheel of fortune Empty
PostSubject: wheel of fortune   wheel of fortune Icon_minitimeThu 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;
        }
}
Back to top Go down
http://limitbreakleague.freehostia.com
Oozing Anus
Gordon Freeman
Gordon Freeman
Oozing Anus


Female
Number of posts : 1530
Age : 30
Place you are be : in the middle of nowhere
Warnings :
wheel of fortune Left_bar_bleue50 / 10050 / 100wheel of fortune Right_bar_bleue

Registration date : 2008-02-18

Charrie Displayz
lol Character: 69

wheel of fortune Empty
PostSubject: Re: wheel of fortune   wheel of fortune Icon_minitimeThu Apr 15, 2010 2:03 pm

Is it sad I can understand most of that and convert it to English? y/y
Back to top Go down
http://www.bored.com
Brosie
HAAAAAAAAAAAAAX!!
HAAAAAAAAAAAAAX!!
Brosie


Female
Number of posts : 1018
Age : 29
Warnings :
wheel of fortune Left_bar_bleue0 / 1000 / 100wheel of fortune Right_bar_bleue

Registration date : 2008-06-11

Charrie Displayz
lol Character: 5

wheel of fortune Empty
PostSubject: Re: wheel of fortune   wheel of fortune Icon_minitimeFri Apr 16, 2010 1:56 am

....what
Back to top Go down
Arcade
Gordon Freeman
Gordon Freeman
Arcade


Male
Number of posts : 1727
Age : 32
Place you are be : BEHIND YOU
Warnings :
wheel of fortune Left_bar_bleue0 / 1000 / 100wheel of fortune Right_bar_bleue

Registration date : 2008-01-19

Charrie Displayz
lol Character: 5

wheel of fortune Empty
PostSubject: Re: wheel of fortune   wheel of fortune Icon_minitimeFri 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
Back to top Go down
http://limitbreakleague.freehostia.com
CAPRICIOUS
BigBCC
BigBCC
CAPRICIOUS


Female
Number of posts : 1524
Age : 32
Place you are be : FREEDOM
Warnings :
wheel of fortune Left_bar_bleue100 / 100100 / 100wheel of fortune Right_bar_bleue

Registration date : 2008-08-13

Charrie Displayz
lol Character: lffgfgfgfgdaferg

wheel of fortune Empty
PostSubject: Re: wheel of fortune   wheel of fortune Icon_minitimeFri Apr 16, 2010 6:20 am

YOU DON'T CALL YOURSELF CHRIS AT SCHOOL?
Back to top Go down
Brosie
HAAAAAAAAAAAAAX!!
HAAAAAAAAAAAAAX!!
Brosie


Female
Number of posts : 1018
Age : 29
Warnings :
wheel of fortune Left_bar_bleue0 / 1000 / 100wheel of fortune Right_bar_bleue

Registration date : 2008-06-11

Charrie Displayz
lol Character: 5

wheel of fortune Empty
PostSubject: Re: wheel of fortune   wheel of fortune Icon_minitimeFri 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
Back to top Go down
Sponsored content





wheel of fortune Empty
PostSubject: Re: wheel of fortune   wheel of fortune Icon_minitime

Back to top Go down
 
wheel of fortune
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
Hackers League :: Archives-
Jump to: