Question: Write method createTeams() that Has no parameters Has return type void Instantiate the member variable of type ArrayList Instantiates two instances of class Team one

Write method createTeams() that

Has no parameters

Has return type void

Instantiate the member variable of type ArrayList

Instantiates two instances of class Team

one for TeamOne

one for TeamTwo

set names for each team as appropriate

add each instance to the ArrayList member variable

Instantiate the member variable of class Scanner passing System.in as the argument to the constructor

Using System.out.println() static method, prompt the user for the human players name

Instantiate an instance of class String set equal to the reference object of class Scanner using its method .next()

Instantiate an instance of class HumanPlayer

Call method .setName() on the reference object of class HumanPlayer passing the value stored in the variable from step g. above

Add the reference object of class HumanPlayer to the instance of class Team representing Team One

Write a for loop to generate three AiPlayer instances

Generate a unique name for each AiPlayer and call method .setName() passing the unique name as an argument

Add one AiPlayer instance to the instance of class Team representing Team One

Add the other two AiPlayer instances to the instance of class Team representing Team Two

Write method outputTeams() so that

It has no parameters

Has a return type of void

Uses an enhanced for loop to loop through the collection of member variable of type ArrayList

Outputs the current Teams name

Uses an enhanced for loop to loop through the collection of class Teams member variable ArrayList

Outputs the current Players name

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!