Alexander.Drokin said: »
Asura.Lolserj said: »
Iro Huro said: »
i also use cpu monitor, weather, and gpu monitor widgets >__>
edit: new page, so i'm gonna throw down some code =D
edit: new page, so i'm gonna throw down some code =D
Code
#include <iostream>
#include <ctime>
using namespace std;
//function prototypes
void printLines(); //prints the seperation lines.
void showTitle(); // Title header.
void callMenu(int &selection); //shows the main menu.
int getRandomNum(); //for the player. generates a random number 1-11.
int getCompRandomNum(); //for the computer. generates a random number between 10-21.
int main()
{
//variables
int menuSelect = 0;
int hitSelect = 0;
int playerRandNum = 0;
int compTotal = 0;
int playerTotal = 0;
//game info
printLines(); //this section shows the title header
showTitle();
printLines();
//main menu and game process
while(menuSelect != 2) //this while statment controls the entire game repeat.
{ //the game will always go back to the main menu when finished
callMenu(menuSelect); //so that the player can choose to play a new game or exit.
printLines();
if(menuSelect == 1) //this if statement lets the program skip the game if the player chooses to exit.
{
while(hitSelect != 2)
{
while(hitSelect != 2) //this while statement lets the player go as many times as they wish to get
{ //as close to 21 as they can.
cout << "Would you like to (1) Hit or (2) Stay? ";
cin >> hitSelect;
if(hitSelect == 1) //this if statement means that if the player chooses to stay, then the game
{ // wont process the random number generation an extra time.
playerRandNum = getRandomNum();
playerTotal += playerRandNum;
cout << "Player Total: " << playerTotal << endl;
}// endif
}//endwhile
compTotal = getCompRandomNum(); //this generates the the number for the computer's hand.
cout << "Computer Total: " << compTotal << endl;
}//endwhile
if(playerTotal == compTotal) //this if statement indicates that if there is a tie,
{ //then the computer should display that it is a tie.
cout << "It's a tie!" << endl;
}//endif
if(playerTotal == 21 || playerTotal > compTotal && playerTotal < 22 && playerTotal != compTotal)
{ //this if statement is for displaying the winning
cout << "Congratulations, you win!" << endl; //text if the player gets 21 or a number higher than the computer.
}//endif
if(playerTotal < compTotal || playerTotal > 21) //this if statment indicates that none of the other conditions were met, which means the player has lost.
{
cout << "You lost!" << endl;
}//endif
//clear variables
hitSelect = 0; //this section clears
playerTotal = 0; //out the variables so
compTotal = 0; //that the numbers from
playerRandNum = 0; //the previous game won't interfere.
printLines(); //prints a dividing line between the last game and the main menu.
}//endif
}//endwhile
return 0;
}//end of main function
//*****function definitions - void functions*****
void printLines()
{
cout << "--------------------" << endl;
} //end of printLines
void showTitle()
{
cout << "***SIMPLE BLACKJACK***" << endl;
cout << "written by Cody Warren" << endl;
} //end showTitle
void callMenu(int &selection)
{
cout << "*****MAIN MENU*****" << endl;
cout << "1. Play" << endl;
cout << "2. Exit" << endl;
printLines();
cout << "What would you like to do? ";
cin >> selection;
} //end callMenu
//*****function definitions - value returning functions*****
int getRandomNum()
{
int num = 0;
srand(static_cast<int>(time(0)));
num = 1 + rand() % (11 - 1 + 1);
return num;
} //end getRandomNum
int getCompRandomNum()
{
int compNum = 0;
srand(static_cast<int>(time(0)));
compNum = 10 + rand() % (21 - 10 + 1);
return compNum;
} //end getCompRandomNumis this a dice game or something?
Blackjack.
ah i only briefly looked at it and saw computer wins and saw rand lol
(cause i had to do a dice program for my class :X)

