Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3B - Favorite Super Bowl Players Work with partner. Discuss, write the code. Submit Player.java and OuterMain.java to BB, individually. In this lab we want

image text in transcribed
image text in transcribed
3B - Favorite Super Bowl Players Work with partner. Discuss, write the code. Submit Player.java and OuterMain.java to BB, individually. In this lab we want to create a project to manage the information of your favorite players Player.java The Player class should contain the data fields such as name, age, etc, for the player. Add some more fields as you wish to store more information. It should also contain the appropriate constructor(s) and the following instant methods: -- Setters - Getters -- a toString() method returns the player's information integrating from the data fields. -- other methods as needed Before you write the code, design your Player class by completing the UML diagram below: Player - name: String - age: int -team: String - mint -set name -Set age set team - set num +toString(): String OuterMain.java In the OuterMain class we would like to utilize the Player class to create a list for your favorite players. Specifically, create an array of type Player of certain size, instantiate player objects and put into the array as elements, modify som player information, print out the whole list, etc. See some hints on the back side Hints: 1. Because the Player is a class, so it can be used like a data type to create array. For example, Player players - new Player (3): will create an array named players, of type Player, of size 3. players players (0) players (1) players (2) Basically, the array players has three elements and each element should be an instance object of type Player. Upon creation, the array is empty because we haven't put anything into each element yet. 2. Let's try to create some real Player objects and put into the players array: // way 1: instantiate a Player object and directly put it into the array players (o] - new Player 0; //create an instance and directly assign to elemento players [1] - new Player('Alex Smith"); //create and assign to elementi //way 2: instantiate a Player object, assign it to a reference, and then put into the array Player playerx new Player("Steve");//create an instance variable playerX players (7 - playerX; assign that instance to the array elementa name name Alex Smith player/ name Steve players players (0) players (1) players [2] We now see that each element of the players array is holding an individual instance of Player. They have their own instance fields and carry their own instance methods. The values for the fields are different due to different constructor they used. 3. Now we have a player list named players. We can modify some information for the player in the list. For example, players[0].setName("Dee Ford"); // change the first player's name to "Dee Ford" 4. To print the information from the list, use a for loop to iterate the array players, for each element, print the info returned by the toString() method. E.g., for(int i = 0; i

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

Nested Relations And Complex Objects In Databases Lncs 361

Authors: Serge Abiteboul ,Patrick C. Fischer ,Hans-Jorg Schek

1st Edition

ISBN: 3540511717, 978-3540511717

More Books

Students also viewed these Databases questions

Question

Write a note on job design.

Answered: 1 week ago

Question

Compute the derivative of f(x)cos(-4/5x)

Answered: 1 week ago

Question

Discuss the process involved in selection.

Answered: 1 week ago

Question

Differentiate tan(7x+9x-2.5)

Answered: 1 week ago

Question

1. Identify three communication approaches to identity.

Answered: 1 week ago

Question

d. Who are important leaders and heroes of the group?

Answered: 1 week ago

Question

3. Describe phases of minority identity development.

Answered: 1 week ago