Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David Kroenke

11th Edition

0132302675, 9780132302678

More Books

Students also viewed these Databases questions

Question

Summarize various training methods.

Answered: 1 week ago