Question
C# help with these methods... public class Game { public Game(int numPlayers, int numRounds) { /*Game's constructor. This is called with the number of players
C# help with these methods...
public class Game {
public Game(int numPlayers, int numRounds) {
/*Game's constructor. This is called with the number of players in the game and the number of rounds that will be played. This method:
+Creates a numPlayers size array of TankController (which is stored as a private field of Game)
+Sets another private field to the number of rounds that will be played
+Creates an array or list collection of Attack (if it's an array, a suitably large array should be created for it, e.g. 100).
No objects of type TankController or Attack should be created here; only the arrays.
-numPlayers will always be between 2 and 8 (inclusive)
-numRounds will always be between 1 and 100 (inclusive)*/
}
public void CreatePlayer(int playerNum, TankController player) {
This method takes a player number (guaranteed to be between 1 and the number of players) and sets the appropriate field in Game's TankController array to player. Note that the value of playerNum is indexed from 1 while arrays are indexed from 0, so CreatePlayer() will need to account for this.
}
public TankController GetPlayerNumber(int playerNum){
//This method takes a player number (playerNum, between 1 and the number of players) and returns the appropriate TankController from the TankController array. Again, note that arrays are indexed from 0 while playerNum is indexed from 1.
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started