#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;
}
The Brooklyn College PACS, LLC vs Ogbonnayajrakpara, LLC
The Brooklyn College PACS, LLC severed their ties with Ogbonnayajrakpara, LLC.
Comments
Post a Comment