Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How are you supposed to start it? Because I am completely lost and need help Thi

ID: 3881626 • Letter: H

Question



How are you supposed to start it? Because I am completely lost and need help

This assignment is a console application. The graphic below is for illustrative purposes only. The real game doesnt look this good (i.e. don't sue me). Your mission, if you accept it, is to write complete a two-player game program. Create a Game class that has an array of 11 characters as a private variable. ·The constructor must create the array and fill it with spaces (ie.). - The display method must print the array using Console.Write and WriteLine. The move method accepts - a char that represents the player (B' for blue, 'R' for red - a position on the board that should be checked 0 and 11) The full method returns true if all the spaces on the board are occupied - The score method computes a score: 4 points for two in a row, 6 points for three in a row, 8 points for four in a row, etc Examples If the board is RRRBBBBRBRB, then red has 6 points, blue has 8 points If the board is RBBRRBBBRRR, then red has 10 points, blue has 10 points Here is the main routine that runs the program. You must write the Game class class Program

Explanation / Answer

colorgame.cs

using System;
class Game{
private char[] array = new char[11];
Game(){
  
for(int i=0;i<11;i++)
array[i] = ' ';
}
  
void Display(){
for(int x=0;x<11;x++){
Console.Write(array[x]);
}
}
  
bool full(){
for(int x=0;x<11;x++){
if (array[x] == ' ')
return false;
}
return true;
}
  
void move(char player, int pos){
array[pos-1] = player;
}
  
int score(char player){
int count = 0;
int score = 0;
for (int i=0;i<11;i++){
if(array[i] == player)
count++;
else{
if(count == 2)
score += 4;
else
if(count == 3)
score += 6;
else
if(count == 4)
score += 8;
count = 0;
  
}
}
return score;
}
}

public class Program{
static void main(string[] args){
Game game = new Game();
int position = 0;
while(game.full() == false){
game.Display();
Console.Write("Red Player- Enter your move: ");
position = Convert.ToInt32(Console.ReadLine());
game.move('R',position);
  
if(game.full() == false){
game.Display();
Console.Write("Blue Player- Enter your move: ");
position = Convert.ToInt32(Console.ReadLine());
game.move('B', position);
}
}
game.Display();
Console.WriteLine("Red Player- Your score is {0}",game.score('R'));
Console.WriteLine("Blue Player- Your score is {0}",game.score('B'));
  
Console.WriteLine();
Console.Write("Press any key to continue.....");
Console.ReadKey();
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote