Quantcast
Viewing all articles
Browse latest Browse all 3

Answer by dwjohnston for Rock, Paper, Scissors 3-part

I'm going to suggest you use a two dimension array look up to determine the win lose matrix.

//-1 = user loses// 0 = tie // 1 = user winsint[][] winArray = new int[            [0, -1, 1],             [1,  0,-1],             [-1, 1, 0]      ]; int userMove;      //get from user inputint computerMove;  //randomly generatedint result = winArray[userMove, computerMove]//now determine what happens if the user wins/loses/ties

Much simpler.


Viewing all articles
Browse latest Browse all 3

Trending Articles