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

The object is to capture as many monsters in as few guesses as possible. Complet

ID: 3712267 • Letter: T

Question

The object is to capture as many monsters in as few guesses as possible. Complete the following instructions listed below in C#
Classes
1. Start with a blank console application. 2. Add a class named “Monster” that has the following attributes: string name. Feel free to make your monster have other attributes, but they are not required. 3. Create a constructor that accepts the name via parameters to create a new monster. 4. Create a property for the name field and use it to access the fields.
Arrays and Randomness
5. Create an empty 1D array that is 13 slots big. Randomly place 3 monsters in the 1D array. These will be hidden to your player, but you may want to output the locations somewhere for yourself during testing and coding. The remainder of the positions should be empty. 6. Create an empty 1D array that will hold three monsters that you will capture.
Methods, Input/Output, Loops, Conditional Expressions
7. Write a method that outputs a structure to the console that simulates the array to the console. 8. Write a method that asks the user select a square using the numbering from your display. Determine if there is monster in that cell or not and give your user appropriate feedback. This method should be called repeatedly from main until the game is done. If the user selects a square that doesn't contain a monster, give feedback to your player - "hot" means there is a monster in an adjacent cell, "cold" means there is not. If the user selects a square that contains a monster, that monster is considered captured and should be moved to the 1D array that represents the monster jail. 9. Give your user feedback in the grid output so that they know when a square has already been chosen. Also give your user feedback regarding captured monsters. You can modify your method from 7 to handle this. 10. Create a mechanism that tracks how many guesses it took to capture all of the monsters. If you’d like, make your game so that a user has a limited number of guesses. 11. Game is over when all three monsters are collected. The object is to capture as many monsters in as few guesses as possible. Complete the following instructions listed below in C#
Classes
1. Start with a blank console application. 2. Add a class named “Monster” that has the following attributes: string name. Feel free to make your monster have other attributes, but they are not required. 3. Create a constructor that accepts the name via parameters to create a new monster. 4. Create a property for the name field and use it to access the fields.
Arrays and Randomness
5. Create an empty 1D array that is 13 slots big. Randomly place 3 monsters in the 1D array. These will be hidden to your player, but you may want to output the locations somewhere for yourself during testing and coding. The remainder of the positions should be empty. 6. Create an empty 1D array that will hold three monsters that you will capture.
Methods, Input/Output, Loops, Conditional Expressions
7. Write a method that outputs a structure to the console that simulates the array to the console. 8. Write a method that asks the user select a square using the numbering from your display. Determine if there is monster in that cell or not and give your user appropriate feedback. This method should be called repeatedly from main until the game is done. If the user selects a square that doesn't contain a monster, give feedback to your player - "hot" means there is a monster in an adjacent cell, "cold" means there is not. If the user selects a square that contains a monster, that monster is considered captured and should be moved to the 1D array that represents the monster jail. 9. Give your user feedback in the grid output so that they know when a square has already been chosen. Also give your user feedback regarding captured monsters. You can modify your method from 7 to handle this. 10. Create a mechanism that tracks how many guesses it took to capture all of the monsters. If you’d like, make your game so that a user has a limited number of guesses. 11. Game is over when all three monsters are collected. The object is to capture as many monsters in as few guesses as possible. Complete the following instructions listed below in C#
Classes
1. Start with a blank console application. 2. Add a class named “Monster” that has the following attributes: string name. Feel free to make your monster have other attributes, but they are not required. 3. Create a constructor that accepts the name via parameters to create a new monster. 4. Create a property for the name field and use it to access the fields.
Arrays and Randomness
5. Create an empty 1D array that is 13 slots big. Randomly place 3 monsters in the 1D array. These will be hidden to your player, but you may want to output the locations somewhere for yourself during testing and coding. The remainder of the positions should be empty. 6. Create an empty 1D array that will hold three monsters that you will capture.
Methods, Input/Output, Loops, Conditional Expressions
7. Write a method that outputs a structure to the console that simulates the array to the console. 8. Write a method that asks the user select a square using the numbering from your display. Determine if there is monster in that cell or not and give your user appropriate feedback. This method should be called repeatedly from main until the game is done. If the user selects a square that doesn't contain a monster, give feedback to your player - "hot" means there is a monster in an adjacent cell, "cold" means there is not. If the user selects a square that contains a monster, that monster is considered captured and should be moved to the 1D array that represents the monster jail. 9. Give your user feedback in the grid output so that they know when a square has already been chosen. Also give your user feedback regarding captured monsters. You can modify your method from 7 to handle this. 8. Write a method that asks the user select a square using the numbering from your display. Determine if there is monster in that cell or not and give your user appropriate feedback. This method should be called repeatedly from main until the game is done. If the user selects a square that doesn't contain a monster, give feedback to your player - "hot" means there is a monster in an adjacent cell, "cold" means there is not. If the user selects a square that contains a monster, that monster is considered captured and should be moved to the 1D array that represents the monster jail. 9. Give your user feedback in the grid output so that they know when a square has already been chosen. Also give your user feedback regarding captured monsters. You can modify your method from 7 to handle this. 10. Create a mechanism that tracks how many guesses it took to capture all of the monsters. If you’d like, make your game so that a user has a limited number of guesses. 11. Game is over when all three monsters are collected. 10. Create a mechanism that tracks how many guesses it took to capture all of the monsters. If you’d like, make your game so that a user has a limited number of guesses. 11. Game is over when all three monsters are collected.

Explanation / Answer

Code

using System;
public class Monster
{
string name;
  
public Monster(string name)
{
this.name=name;
}
  
public string monster_Name
{
get
{
return this.name;
}
set
{
this.name = value;
}
}
  
}
class MainClass
{
static Monster[] array=new Monster[13];
  
static Monster[] jail=new Monster[3];
  
static int[] disp=new int[13];
  
static int j=0;
  
public static void display(int[] disp)
{
Console.Write(" --------------------------------------------------------- ");
Console.Write("| ");
for(int i=0;i<13;i++)
{
if(disp[i]==-1)
Console.Write("x | ");
else
Console.Write(disp[i]+ " | ");
}
Console.Write(" --------------------------------------------------------- ");
}
  
public static void check(int i)
{
int flag=0;
disp[i-1]=-1;
  
if (array[i-1]==null)
{
if(i==13)//if last cell
{
if(array[11]!=null)
flag=1;
}
if(i==1)//if first cell
{
if(array[1]!=null)
flag=1;
}
if(i>1 && i<13)//if any intermediate cell
{
if(array[i-2]!=null || array[i]!=null)
flag=1;
}
if(flag==1)
Console.WriteLine(" HOT");
else
Console.WriteLine(" COLD");
  
}
else
{
jail[j]=array[i-1];
  
Console.WriteLine(" Hey, you found my monster "+array[i-1].monster_Name+" ");
array[i-1]=null;
  
j++;
Console.Write(" ------------------- |");
  
for(int k=0;k<3;k++)
{
if(jail[k]!=null)
Console.Write(jail[k].monster_Name+"|");
else
Console.Write(" |");
}
Console.Write(" ------------------- ");
}
  
}
  
  
public static void Main (string[] args)
{
int index,choice,guesses=0;
  

for(int i=0;i<13;i++)
{
array[i]=null;
disp[i]=i+1;
}
  
Random rand=new Random();
  
for(int i=1;i<4;)
{

index=rand.Next(0,12);
if(array[index]==null)
{
array[index]=new Monster("Monu"+i);
i++;
}
}
while(jail[2]==null)
{
guesses++;
display(disp);
  
Console.WriteLine(" ::Please select the choice:: ");
  
choice=Convert.ToInt32(Console.ReadLine());
  
check(choice);
}
  
Console.WriteLine(" ::You found all my monsters in "+guesses+" guesses:: ");
  
}
}