Simple rock-paper-scissors game This is a simple rock-paper-scissors program implemented using C++. Any feedback or suggestions for improvement are welcome. 

Code:

main.cpp:

#include &lt;iostream&gt;
#include &lt;string&gt;
#include "rock-paper-scissorss.h"
using namespace std;

void whoWon(string player_move, string computer_move){
    if(player_move == "rock"){
        if(computer_move == "paper")
            cout&lt;&lt;"You chose rock and the computer chose paper, the computer wins!"&lt;&lt;endl;

        else if(computer_move == "scissors")
            cout&lt;&lt;"You chose rock and the computer chose scissors, you win!"&lt;&lt;endl;

        else
            cout&lt;&lt;"You chose rock and the computer chose rock, it's a tie!"&lt;&lt;endl;
    }

    else if(player_move == "paper"){
        if(computer_move == "scissors")
            cout&lt;&lt;"You chose paper and the computer chose scissors, the computer wins!"&lt;&lt;endl;

        else if(computer_move == "rock")
            cout&lt;&lt;"You chose paper and the computer chose rock, you win!"&lt;&lt;endl;

        else
            cout&lt;&lt; "You chose paper and the computer chose paper, it's a tie!"&lt;&lt;endl;
    }

    else{
        if(computer_move == "rock")
            cout&lt;&lt;"You chose scissors and the computer chose rock, the computer wins!"&lt;&lt;endl;

        else if(computer_move == "paper")
            cout&lt;&lt;"You chose scissors and the computer chose paper, you win!"&lt;&lt;endl;

        else
            cout&lt;&lt;"You chose scissors and the computer chose scissors, it's a tie!"&lt;&lt;endl;
    }
}

int main(int argc, char** argv) {
  \
  char play_again = 'y';
  cout&lt;&lt;"Please enter your name: "&lt;&lt;endl;
  string name;
  getline(cin,name);
  cout&lt;&lt;"Hello "&lt;&lt;name&lt;&lt;", welcome to Rock-Paper-Scissors!"&lt;&lt;endl;

    Player player_1(name);
  while(play_again == 'y'){


    cout&lt;&lt;"Please enter the move you wish to make: "&lt;&lt;endl;
    string move;
    getline(cin,move);
    while(1){
        if((move == "rock") || (move == "paper") || (move == "scissors")){

            player_1.setMoveChoice(move);
            break;
        }

        else{
            cout&lt;&lt;"Invalid move choice! Please enter rock, paper, or scissors"&lt;&lt;endl;
            getline(cin,move);
        }
    } 


    Computer com_1;
    com_1.setMoveChoice();

   string p_move = player_1.getMoveChoice();
   string c_move = com_1.getMoveChoice();


   whoWon(p_move,c_move);



   cout&lt;&lt;"Would you like to play again?(y/n)"&lt;&lt;endl;

   cin&gt;&gt;play_again;
   cin.ignore();



    } 



 return 0;
}


rock-paper-scissors.cpp:

#include "rock-paper-scissorss.h"
#include &lt;cstdlib&gt;

Computer :: Computer(){
    num_generated = rand() % 3 + 1;
}

void Computer ::  setMoveChoice(){
   if(num_generated == 1)
       move_selected = "rock";

   else if(num_generated == 2)
       move_selected = "paper";

   else
       move_selected = "scissors";

}

string Computer :: getMoveChoice(){
    return move_selected;
}




Player :: Player(string name){
    player_name = name;

}

void Player :: setMoveChoice(string choice){
    move_selected = choice;
}

string Player :: getMoveChoice(){
    return move_selected;
}


rock-paper-scissorss.h:

#ifndef ROCK_PAPER_SCISSORSS_H
#define ROCK_PAPER_SCISSORSS_H

#include &lt;iostream&gt;
#include &lt;string&gt;
using namespace std;



class Computer{

private:
    int num_generated;
    string move_selected;

public:
    Computer();
    void setMoveChoice();
    string getMoveChoice();

};

class Player{

private:
    string move_selected;
    string player_name;

public:
    Player(string);
    void setMoveChoice(string move);
    string getMoveChoice();

};

#endif /* ROCK_PAPER_SCISSORSS_H */
Welcome to codereview. Here's a selection of suggestions.

num_generated = rand() % 3 + 1;


This is probably fine for this use case. Be aware that 


rand() is generally agreed not to be random enough for many uses where you need a random number. Consider instead using the &lt;random&gt; header.
Using %3 to condense the spread of random numbers into 0 through 2 slightly biases the result. Consider what happens if rand() uniformly and randomly produced numbers between 0 and 4 and you used this approach: getting low values would be slightly more likely than getting high values. 
rand() requires seeding with srand() or the results won't vary from run to run.
The + 1 goes from a range of 0 through 2 to a range of 1 through 3. That's not inherently a problem (it doesn't cause any issues with this program) but the very strong convention is that counting starts from 0. If, say, you had an array of moves and you used this random number to look up the array, one of the moves should be move 0. 


Putting that in the constructor, specifically 

Computer :: Computer(){
    num_generated = rand() % 3 + 1;
}


means that a given Computer object only ever produced one move. It would probably be better if you could reuse the same object.

public:
    Computer();
    void setMoveChoice();
    string getMoveChoice();
};


Consider setting up some sort of inheritance structure. If there was a base class Player which HumanPlayer and ComputerPlayer inherited from, it would be easier to write the program flexibly. You could have the same game logic, and swap in different sorts of players for PvP games, CvC simulations, and potentially new additions such as playing against another player on the internet.

move_selected = "rock";


For a problem like this, it's better to use integer (or better still enum) types. Keep strings for when the task is inherently about the text (including text input and output) rather than the thing the text represents. Among other things, strings are expensive to work with and tend to confuse the compiler in places where it would otherwise be able to help point out bugs. 

On the topic of strings, there is a lot of redundancy in whoWon. Consider separating out the logic of working out who won from the logic of displaying it. Every output has the form. 

cout&lt;&lt; "You chose " &lt;&lt; player_move &lt;&lt; " and the computer chose "&lt;&lt; computer_move &lt;&lt;", " &lt;&lt; result &lt;&lt;endl;


A c++ specific issue:

using namespace std;


It is generally agreed that this should be avoided, especially in header files. Better to write std::string and such like in full. Otherwise there can be ambiguity (including in files that at some level include that header, which the programmer is not fully aware of) between functionality defined by the standard library and functionality defined by the programmer or third party libraries.

endl


C++ programmers generally prefer putting a newline (\n) into the string rather than using endl: endl both pushes a newline and forces the output buffer to flush. Only use it when you need the buffer to flush and the text to display immediately.

while(play_again == 'y'){


If you want to use a loop that always runs once, and then checks whether to run again at the end, consider a do { ... } while () loop instead. This avoids having to force the repeat condition before starting.