Question: C++ PROGRAM When I input 3 S P R, it was suppoesed to pop up L W T. But it showed L L L. The

C++ PROGRAM When I input 3 S P R, it was suppoesed to pop up L W T. But it showed L L L. The moveNo is not working.

#include #include "computer.h" #include "human.h" #include "referee.h" using namespace std;

int main() { human h; computer c; referee r; r.compare(h,c); return 0; }

#include #include "computer.h" using namespace std;

//dumb computer, only choose R

char computer:: move(){ return 'R';

}

#ifndef COMPUTER_H #define COMPUTER_H class computer{ public: char move(); };

#endif // COMPUTER_H

#include #include "human.h" using namespace std;

human::human(){ cin>>totalMoves;

moves=new char[totalMoves]; for(int i=0;i

cin>>moves[i]; } } char human::move(){

char returnH=moves[moveNo];

return returnH; }

#ifndef HUMAN_H #define HUMAN_H class human { public: char*moves; int moveNo; int totalMoves; human(); char move(); };

#endif // HUMAN_H

#include #include "referee.h" #include "computer.h" #include "human.h" using namespace std;

void referee::compare(human h, computer c){ //char result='T';

char humanMove=h.move(); char computerMove=c.move();

int totalMoves=h.totalMoves; for(int i=0;i

}cout<

#ifndef REFEREE_H #define REFEREE_H #include "computer.h" #include "human.h" class referee{ public: void compare(human h, computer c);

};

#endif // REFEREE_H

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!