Thread: rock paper Scissors

  1. #1
    Registered User
    Join Date
    Jul 2006
    Posts
    4

    rock paper Scissors

    i'm supposed to do a rock paper scissors program for my class and here's how my teacher wants it to look like.

    Your choice: R)ock, S)cissors, P)aper, or Q)uit: x
    Please enter R for rock, S for scissors, P for paper, or Q to quit: s
    Computer chose Paper - you win.

    Your choice: R)ock, S)cissors, P)aper, or Q)uit: p
    Computer chose Scissors - you lose.

    Your choice: R)ock, S)cissors, P)aper, or Q)uit: R
    Computer chose Rock - it's a draw.

    Your choice: R)ock, S)cissors, P)aper, or Q)uit: R
    Computer chose Scissors - you win.

    Your choice: R)ock, S)cissors, P)aper, or Q)uit: Q

    Your wins: 2
    Computer's wins: 1
    Number of draws: 1

    Code:
    #include <iostream>
    #include <cstdlib>
    #include <ctime>
    #include <string>
    // These includes let us work with vectors:
    #include <vector>
    #include <algorithm>
    
    // This include lets us read and write files:
    #include <fstream>
    
    using namespace std;
    
    /*
    	This is a global type -- it is defined outside
    	of a function, so it is available to *all* functions
    */
    enum winnerType = {PLAYER, COMPUTER, DRAW};
    
    int main()
    {
    	winnerType winner;
    	
    	// declare variables
    	giveDirections( )
    	
    	playerChoice = getPlayerInput( )
    	while (playerChoice != 'Q')
    	{
    		computerChoice = getComputerChoice( );
    		
    		winner = determineWinner( playerChoice,
    			computerChoice );
    	
    		if (winner == PLAYER)
    		{
    			playerWins++;
    			display congratulations
    		}
    		else if (winner == COMPUTER)
    		{
    			computerWins++;
    			cout <<  "Sorry you lost this one" << endl;
    		}
    		else
    		{
    			draws++;
    		}
    		totalGames++;
    		player makes choice again
    	}
    	display playerWins
    	display computerWins
    	display draws
    	display totalGames
    
    	system("PAUSE");
    	return 0;	
    	
    }
    
    void giveDirections( )
    {
    	// you figure this one out
    }
    
    /*
    	do
    	{
    		input a character
    		convert to upper case
    		if (character != R or S or P or Q)
    		{
    			give an error message
    		}
    	} while (character != R or S or P or Q);
    	return character
    	[note: "or" is English; you will need && in C++]
    */
    char getPlayerInput( )
    {
    }
    
    /*
    	char choice = ' ';
    	set r to a random number from 0..2
    	switch (r)
    	{
    		0: choice = 'R'
    		1: choice = 'S'
    		2: choice = 'P'
    	}
    	return choice
    */
    char getComputerChoice( )
    {
    }
    
    /*
    	winnerType theWinner;
    	if (player == computer)
    	{
    		theWinner = DRAW;
    	}
    	else if ( player=='R'/computer=='S' OR/AND???
    		player=='S'/computer=='P' OR/AND???
    		player=='P'/computer=='R')
    	{
    		theWinner = PLAYER;
    	}
    	else
    	{
    		theWinner = COMPUTER;
    	}
    	return theWinner;
    
    */
    winnerType determineWinner( char player, char computer )
    {
    	
    }

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Code:
    	// you figure this one out
    Sounds good to me. If you actually have a question, I suppose you could ask.

  3. #3
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    Yes, and your question is ... ?

  4. #4
    Registered User
    Join Date
    Jun 2007
    Posts
    41
    Ha thats sad... its practically handed to you. Perhaps the question you should ask is: Why am I taking this class?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Rock Paper Scissors Game
    By tbca in forum C++ Programming
    Replies: 12
    Last Post: 07-09-2007, 12:16 PM
  2. need help with rock paper scissors program
    By Mshock in forum C Programming
    Replies: 3
    Last Post: 04-22-2006, 07:44 AM
  3. Another rock paper scissor question
    By mattflick in forum C Programming
    Replies: 11
    Last Post: 09-29-2005, 09:41 PM
  4. PRS Help
    By SpudNuts in forum C Programming
    Replies: 10
    Last Post: 08-07-2005, 01:14 PM
  5. Rock, Paper, Scissors
    By Twiggy in forum C Programming
    Replies: 9
    Last Post: 11-06-2001, 05:06 AM