Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Add player class to the project. - Add public data: int numPlayers - Instantiate in main and test. Add a print statement Add seLinkList class

  • Add player class to the project. - Add public data: int numPlayers - Instantiate in main and test. Add a print statement
  • Add seLinkList class to the project. - This class should be a Single Linked List that holds data. Code it with basic Java references. - Add public data: - seLinkList next; //reference to next node - int a; - int b; - ine c; - Add constructor. - Instantiate in main and test. - Add a print statement.
  • Copy the playerData class ,Use PlayerData and its getMyData method to retrieve the sample data in your Player.java class.
  • Inside your player,java: - Add selinkList head reference AND rework the constructor. - Add addPlayer method. This function should add a single seLinkList node to the player class. Remember to update the head pointer in player class
  • Inside your player,java: - Add initializeList method. This function should take the player_array data and loop through the entire list, adding new nodes one at a time to the player's list. Use addPlayer() for this functionality.
  • Inside your selinkList.java: - Add index field to selinkliss. - Index starts as 0,1,2... for each node. - Modify the constructors and initializing functions. - Inside your player.java: - Add findMaxWeight() method. - Walk through the linked list and find the naximum weight. You Cannot use the playerData array, only use the linked list. - Weight is defined as: Weight=a+b+c
  • Print out the maximum and its node. Ex.Max weight playe - Node (index,a,b,c) and its weight
  • Refactor seLinklist to be a doubly link list We want the list to be doubly link so we can quickly remove any node. - Refactor the code to have both prev and nexa. You need to adjust fields in selinkList.
  • Add removeNode method to Player class - doublelink Branch & Add removeNode() inside player java and make sure you handle the following cases: - Only node - First node - Last node - Middle node
  • Add findMin Weight method to Player class
  • Add findMin Weight() in player.java to walk through the list, find the minimum weight, and return its node. - Refactor findMaxWeight() to return the node with maximum weight as well.
  • Add findMinMax Weight method to Player class
  • Add findMinMaxWeight() method to player.java to finds both Min and Max with a single walk of the nodes. Return both the minWeightNode and the maxWeightNode
imageimage

public class PlayerData { public int a; public int b; public int c; PlayerData [] myData; Player Data (int dataA, int dataB, int dataC) { this.a = dataA; this.b= dataB; this.c = dataC; } PlayerData () { myData = new PlayerData [] { new PlayerData( 22, 9, 9), new PlayerData( 3, 26, 9), new PlayerData( 23, 24, 1), new PlayerData( 20, 13, 6), new PlayerData ( 15, 19, 2), new PlayerData ( 14, 4, 24), new PlayerData( 3, 6, 14), new PlayerData( 10, 10, 11), new PlayerData( 5, 7, 22 ), new PlayerData( 1, 11, 0), new PlayerData( 26, 19, 24), new PlayerData( 5, 28, 9), new PlayerData( 6, 24, 17), new PlayerData( 29, 22, 24), new PlayerData( 24, 10, 22), new PlayerData( 22, 11, 13), new PlayerData( 7, 12, 27), new PlayerData( 3, 11, 22), new PlayerData( 16, 12, 28), new PlayerData( 28, 28, 19), new PlayerData( 17, 21, 13), new PlayerData( 1, 24, 23 ), new PlayerData ( 12, 10, 20 ), new PlayerData ( 22, 8, 10), new PlayerData( 6, 3, 13 ),

Step by Step Solution

3.52 Rating (149 Votes )

There are 3 Steps involved in it

Step: 1

To complete the task we need to follow the provided instructions and add the required classes and methods to the project Heres the implementation java ... 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

Java An Introduction To Problem Solving And Programming

Authors: Walter Savitch

8th Edition

0134462033, 978-0134462035

More Books

Students also viewed these Programming questions

Question

How do fixed annuities differ from variable annuities?

Answered: 1 week ago