All pastes #1586525 Raw Edit

Assignment 04 main.cpp

public cpp v1 · immutable
#1586525 ·published 2009-09-30 19:28 UTC
rendered paste body
// Name: Byron Samaripa// Date:09/22/09// Assignment: 4// Filename: main.cpp// Description: This program plays a game of Rock-paper-scissors agains the user.//              The user will input his selection and the computer will respond with a//              corresponding move, it will then decide who won the round.#include <iostream>#include <cstdlib>#include "brain.h"using namespace std;// Function Prototypesint finalShowdown(int,int);int userCheck(int);int computerCheck(int);//Used in looping statementbool runAgain = true;char yesOrNo = 'Y';int main(){    while(runAgain)    {        // Declarations        int userChoice;        int computerChoice;        bool errorCheck = true;        // Prompts the user to enter his selection.        while (errorCheck)        {            cout << "Type Rock[1], Paper[2], or Scissors[3]: ";            cin >> userChoice;            if (userChoice == 1 || userChoice == 2 || userChoice == 3)            {                errorCheck = false;            }            else if (userChoice != 1 || userChoice != 2 or userChoice != 3)            {                cout << "Invalid Number!\n";            }        }        //Error Checking        if (userChoice > 3)        {            cout << "Please input a number between 1 and 3!";            return 0;        }        // Genrates random number for Computers choice        srand(time(0));        computerChoice = rand() % 3 + 1;        // Uses the defined functions to decide and output the result        userCheck(userChoice);        computerCheck(computerChoice);        finalShowdown(userChoice,computerChoice);        cout << "Would you like to play again?[Y]/[n]\n:";        cin >> yesOrNo;        if (yesOrNo == 'N' || yesOrNo == 'n')        {            runAgain = false;        }    }}