Add player class to the project. - Add public data: int numPlayers - Instantiate in main and
Fantastic news! We've Found the answer you've been seeking!
Question:
- 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
Related Book For
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch
Posted Date: