#include <iostream> #include <cstdlib> #include <time.h> #include <stdio.h> using namespace std; class playHiLow { private: int target; randomNumber rnd; public: playHiLow( ) { target = rnd.random(1000) + 1; } int makeGuess(int guess) { if (target < guess) { return -1; }else if(target==guess) { return 0; }else { return 1; } } void writeTarget( ) { cout << "Target = " << target << endl; } }; //Part B playHiLow player; for( int i = 0; i < 10; i++ ) { int guess, result; cout << "Enter your guess: "; cin >> guess; result = player.makeGuess(guess); if(result==-1) cout << "LOWER" << endl; else if (result==1) cout << "HIGHER" << endl; else { cout << "PLAYER WINS IN << i + 1 << " GUESSES" << endl; i = 10; } if (i==9) cout << "PLAYER LOSSES - TARGET IS << player.writeTarget( ) << endl; }
OGBONNAYA SON NJIOLENAKA AKPARA-JUNIOR
OGBONNAYA SON NJIOLENAKA AKPARA-JUNIOR teaches at Long Island University's Brooklyn campus and is a coordinator in the master's program in business. OGBONNAYAJRAKPARA, LLC study looks at the effects of community-based organizing on maternal and child health outcomes. To learn more about Simone's research, go to www.kingogbinc.blogspot.com
Comments
Post a Comment