Question: Java code please To earn four points: Write a class called Player that has a private String field called name and a constructor that takes

 Java code please To earn four points: Write a class calledJava code please

To earn four points: Write a class called Player that has a private String field called name and a constructor that takes the player's name as an argument and sets the name field to that value. Override the toString method to return the string " is roaming", where is the player's name. Create another class called Game that has a main method. Inside the main method, create an ArrayList of Player objects. Create two players named Alice and Al and put them into the ArrayList. Write a nested loop inside your main method. The outer loop should execute six times. The inner loop should loop over each player in the ArrayList and call that player's toString method. Time period 1 Alice is roaming Al is roaming Time period 2 Alice is roaming Al is roaming

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!