Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

EXERCISE 1: (60 POINTS) This exercise is on the application of Unordered Lists.

ID: 3600573 • Letter: E

Question

EXERCISE 1: (60 POINTS) This exercise is on the application of Unordered Lists. You will need the source codes for Node.java, LinkedList.java and List.java discussed in the lectures. You will also need the text file nhlstats.txt (these files are available to download along with the link to this assignment) Before you begin this assignment, it will be useful to study the Expense.java, ExpenseList.java and ExpenseListDemo.java programs that were discussed in the lectures. You will also need knowledge of File Processing and String Tokenizer from CSCI 1101. You are given the raw scores of various NHL players' regular hockey games in the file nhlstats.txt. The file has data organized in the following manner: Name Marchand Eberle Pos Team GP BOS 45 EDM 48 18 16 18 21 PIM SOG GWG 27 16 91 133 3 LW Note: The first row is not there in the actual nhlstats.txt file. It just tells you what each column stands for. The columns are as follows: The first column is the name of the player. Pos stands for Position. In this column, C means Center, LW means Left Wing, RW means Right Wing, LD means Left Defense, RD means Right Defense, and G means Goalie. GP stands for Games Played. G stands for Goals scored. A stands for Assists PIM stands for Penalties In Minutes SOG stands for Shots on Goal GWG stands for Game Winning Goals. So, for example, in the above file, Marchand plays Left Wing, belongs to team BOS (Boston Bruins), played 45 games during the season, scored 18 goals, had 18 assists, spent 27 penalty minutes, had 91 shots on goal and 5 game winning goals Now, from these numbers, hockey statisticians calculate interesting information, such as the following. 1. Player with the highest points. Points Goals Assists. For example, Marchand has 36 2. 3. 4. points and Eberle has 37 points Player with the maximum penalty points Player with the most game winning goals Etc. Here is what your program should do. Follow these steps.

Explanation / Answer


package chegg;
public class PlayerRecord {
private String name;
private String pos;
private String team;
private int gameplayed;
private int goalScored;
private int assists;
private int penalitiesInMinute;
private int shoutsOnGoal;
private int gamesWinningGoals;
public PlayerRecord(String name, String pos, String team, int gameplayed,
int goalScored, int assists, int penalitiesInMinute,
int shoutsOnGoal, int gamesWinningGoals) {
super();
this.name = name;
this.pos = pos;
this.team = team;
this.gameplayed = gameplayed;
this.goalScored = goalScored;
this.assists = assists;
this.penalitiesInMinute = penalitiesInMinute;
this.shoutsOnGoal = shoutsOnGoal;
this.gamesWinningGoals = gamesWinningGoals;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPos() {
return pos;
}
public void setPos(String pos) {
this.pos = pos;
}
public String getTeam() {
return team;
}
public void setTeam(String team) {
this.team = team;
}
public int getGameplayed() {
return gameplayed;
}
public void setGameplayed(int gameplayed) {
this.gameplayed = gameplayed;
}
public int getGoalScored() {
return goalScored;
}
public void setGoalScored(int goalScored) {
this.goalScored = goalScored;
}
public int getAssists() {
return assists;
}
public void setAssists(int assists) {
this.assists = assists;
}
public int getPenalitiesInMinute() {
return penalitiesInMinute;
}
public void setPenalitiesInMinute(int penalitiesInMinute) {
this.penalitiesInMinute = penalitiesInMinute;
}
public int getShoutsOnGoal() {
return shoutsOnGoal;
}
public void setShoutsOnGoal(int shoutsOnGoal) {
this.shoutsOnGoal = shoutsOnGoal;
}
public int getGamesWinningGoals() {
return gamesWinningGoals;
}
public void setGamesWinningGoals(int gamesWinningGoals) {
this.gamesWinningGoals = gamesWinningGoals;
}
@Override
public String toString() {
return "PlayerRecord [name=" + name + "]";
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + assists;
result = prime * result + gameplayed;
result = prime * result + gamesWinningGoals;
result = prime * result + goalScored;
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + penalitiesInMinute;
result = prime * result + ((pos == null) ? 0 : pos.hashCode());
result = prime * result + shoutsOnGoal;
result = prime * result + ((team == null) ? 0 : team.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
PlayerRecord other = (PlayerRecord) obj;
if (assists != other.assists)
return false;
if (gameplayed != other.gameplayed)
return false;
if (gamesWinningGoals != other.gamesWinningGoals)
return false;
if (goalScored != other.goalScored)
return false;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
if (penalitiesInMinute != other.penalitiesInMinute)
return false;
if (pos == null) {
if (other.pos != null)
return false;
} else if (!pos.equals(other.pos))
return false;
if (shoutsOnGoal != other.shoutsOnGoal)
return false;
if (team == null) {
if (other.team != null)
return false;
} else if (!team.equals(other.team))
return false;
return true;
}
}

------------- End-----------------

package chegg;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class NHLStats {
private List<PlayerRecord> playerList;
public NHLStats(){
playerList = NHLStats.readFile();
System.out.println(playerList.toString());
}
public static void main(String[] args) {
new NHLStats();
}
private static List<PlayerRecord> readFile() {
int heading = 0;
BufferedReader br = null;
FileReader fr = null;
List<PlayerRecord> fileContent = new ArrayList<PlayerRecord>();
try {
fr = new FileReader("E://PlayerRecord.txt");
br = new BufferedReader(fr);
String sCurrentLine;
while ((sCurrentLine = br.readLine()) != null) {
if (heading == 0) {
heading++;
continue;
}
heading++;
String[] tabValues = sCurrentLine.split(" ");
fileContent.add(new PlayerRecord(tabValues[0], tabValues[1],
tabValues[2], Integer.parseInt(tabValues[3]), Integer
.parseInt(tabValues[4]), Integer
.parseInt(tabValues[5]), Integer
.parseInt(tabValues[6]), Integer
.parseInt(tabValues[7]), Integer
.parseInt(tabValues[8])));
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (br != null)
br.close();
if (fr != null)
fr.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
return fileContent;
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote