Hello, the code below is for a Rock, Paper, Scissors application. Can you show me how to modify the code so that it includes an array or a list?

Description


Hello, the code below is for a Rock, Paper, Scissors application. Can you show me how to modify the code so that it includes an array or a list? Also, can you show me how to modify it so that multiple users can run the application and have it display the high scores of the users? Right now I only have one class in the code, I would ideally like to have three classes. Here is the code:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace ROCKPAPERSCISSORSAPP{  class Program  {    static void Main(string[] args)    {      string inputPlayer, inputCPU;      int randomInt;      bool playAgain = true;      while (playAgain)      {        int scorePlayer = 0;        int scoreCPU = 0;        while (scorePlayer < 3 && scoreCPU < 3)        {          Console.Write("Choose between ROCK, PAPER, and SCISSORS:  ");          inputPlayer = Console.ReadLine();          inputPlayer = inputPlayer.ToUpper();          Random rnd = new Random();          randomInt = rnd.Next(1, 4);          switch (randomInt)          {            case 1:              inputCPU = "ROCK";              Console.WriteLine("CPU chose Rock");              if (inputPlayer == "ROCK")              {                Console.WriteLine("DRAW!!nn");              }              else if (inputPlayer == "PAPER")              {                Console.WriteLine("Player WINS!!nn");                scorePlayer++;              }              else if (inputPlayer == "SCISSORS")              {                Console.WriteLine("CPU WINS!!nn");                scoreCPU++;              }              break;            case 2:              inputCPU = "PAPER";              Console.WriteLine("Computer chose PAPER");              if (inputPlayer == "PAPER")              {                Console.WriteLine("DRAW!!nn");              }              else if (inputPlayer == "ROCK")              {                Console.WriteLine("CPU WINS!!nn");                scoreCPU++;              }              else if (inputPlayer == "SCISSORS")              {                Console.WriteLine("PLAYER WINS!!nn");                scorePlayer++;              }              break;            case 3:              inputCPU = "SCISSORS";              Console.WriteLine("Computer chose Scissors");              if (inputPlayer == "SCISSORS")              {                Console.WriteLine("DRAW!!nn");              }              else if (inputPlayer == "ROCK")              {                Console.WriteLine("Player WINS!!nn");                scorePlayer++;              }              else if (inputPlayer == "PAPER")              {                Console.WriteLine("CPU WINS!!nn");                scoreCPU++;              }                break;              default:              Console.WriteLine("Invalid entry!");              break;          }          Console.WriteLine("nnSCORES:tPlAYER:t{0}tCPU:t{1}", scorePlayer, scoreCPU);        }        if (scorePlayer == 3)        {          Console.WriteLine("Player WON!");        }        else if (scoreCPU == 3)        {          Console.WriteLine("CPU WON!");        }                Console.WriteLine("Do you want to play again?(y/n)");        string loop = Console.ReadLine();        if (loop == "y")        {          playAgain = true;          Console.Clear();        }        else if (loop == "n")        {          playAgain = false;        }      }    }  }}

Question

Hello, the code below is for a Rock, Paper, Scissors application. Can you show me how to modify the code so that it includes an array or a list?

  • Written in: 17-Oct-2019
  • Paper ID: 351286
Price: $ 15
 

Use the Order Now button below to Place a New Order for an Original, High-Quality Paper that passes all Plagiarism Checkers

Order Now




About this Question

STATUS

Approved

DATE ANSWERED

Oct 17, 2019

EXPERT

N/A

ANSWER RATING

Need Help with an Assignment?

Get Help with an Assignment

SSL Certificate website security