Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <stdio.h>
- #include <iostream>
- #include <time.h>
- #include <windows.h>
- //cout <<"\n" <<randomNumber();
- //Sleep(1000);
- //cout <<"\n" <<randomNumber();
- //Sleep(1000); cout<<"\b";
- using namespace std;
- int PlayGame();
- void Introduction(void);
- void UpdateCount (int, int&, int&, int&);
- char AskRepeat();
- void Report (int, int, int);
- int randomNumber();//r
- void Goodbye(void);
- int main(int argc, char *argv[])
- {
- char selection;
- Introduction();
- cout<<"Please make a selection (1-3): ";
- cin >> selection;
- system("cls");
- if (selection == '1')
- {
- PlayGame();
- }
- //else if (selection == 2)
- //UpdateCount();
- else
- Goodbye();
- system("PAUSE");
- return EXIT_SUCCESS;
- }
- void Introduction(void)
- {
- cout<<"\t\t===========================================\n"
- <<"\t\t\tGame of BlackJack by Rohin A. \n"
- <<"\t\t===========================================\n"
- <<"\n\n 1. Play Black Jack"
- <<" \n 2. Game Stats"
- <<"\n\n 3. Quit Program\n\n\n\n\n";
- }
- int PlayGame()
- {
- //Plays one game of 21 and returns an indication of the winner
- //Post: One game has been played, and a code returned indicating the winner:
- // 0=draw 1=user won 2=computer won
- cout<<"\nComputer's Hand...\n\n ";
- int compNum[3], userNum[3];
- compNum[1] = randomNumber();
- cout<< compNum[1] <<" "; Sleep(1000);
- compNum[2] = randomNumber();
- cout<< compNum[2] <<" "; Sleep(1000);
- compNum[3] = randomNumber();
- cout<< compNum[3] <<" "; Sleep(1000);
- compNum[0] = compNum[1] + compNum[2] + compNum[3];
- cout<<" Total: " <<compNum[0] <<"\n\n\n\n";
- cout<<"Your Hand...\n\n ";
- userNum[1] = randomNumber();
- cout<< userNum[1] <<" "; Sleep(1000);
- userNum[2] = randomNumber();
- cout<< userNum[2] <<" "; Sleep(1000);
- userNum[3] = randomNumber();
- cout<< userNum[3] <<" "; Sleep(1000);
- userNum[0] = userNum[1] + userNum[2] + userNum[3];
- cout<<" Total: " <<userNum[0] <<"\n\n";
- }
- void UpdateCount (int result, int &wins, int &losses, int&draws)
- {
- //Increment one of th counters as determined by Result
- //Pre: Result is either 0, 1 or 2
- //Post: Either Wins, Losses, or Draws has been incremented based upon wheather Result
- // is 0, 1 or 2.
- }
- char AskRepeat()
- {
- //Asks the user if another game is desired and returns response
- //Post: User has been responded with y, Y, n, or N. The response is returned
- }
- void Report(int Wins, int Losses, int Draws)
- {
- //Reports the current results
- //Pre: Wins, Losses, Draws represent the current results
- //Post: The current results have been displayed
- }
- int randomNumber()
- {
- srand(time(NULL)); // This seeds the random number generator
- int randNumber = rand(); // This gets a random number as an integer
- const int MAX = 10; // Sets a constant variable for the maximum
- // The MAX variable says there will be 100 numbers in the allowed
- // responses and the number 1 says zero will not be included
- int number = (randNumber % MAX) + 1;
- return number; // This sends the random number back to main
- }
- void Goodbye(void)
- {
- system("cls");
- cout<<"goodbyeeee!\n\n\n\n\n\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement