huge update idk

This commit is contained in:
CT
2026-04-25 17:14:35 -05:00
parent 1bd20c4af4
commit 3b2520df35
8 changed files with 89 additions and 8 deletions

BIN
HockeyPlayer.class Normal file

Binary file not shown.

View File

@@ -1,6 +1,6 @@
public class HockeyPlayer {
String name;
int goals, assists, gamesWon, gamesLost;
private String name;
private int goals, assists, gamesWon, gamesLost;
public HockeyPlayer(String n, int g, int a, int gw, int gl) {
name = n;
@@ -14,6 +14,26 @@ public class HockeyPlayer {
this.name = name;
}
public String getName() {
return name;
}
public int getGoals() {
return goals;
}
public int getAssists() {
return assists;
}
public int getGamesWon() {
return gamesWon;
}
public int getGamesLost() {
return gamesLost;
}
public int getPoints() {
return goals + assists;
}
@@ -25,12 +45,16 @@ public class HockeyPlayer {
public String toString() {
String s =
String.format(
"Name: %s%nGoals: %d%tAssists: %d%tPoints: %d%nGames Won: %d%tGames Lost: %d%tGames"
"Name: %s%nGoals: %d\tAssists: %d\tPoints: %d%nGames Won: %d\tGames Lost: %d\tGames"
+ " Played: %d%n",
name, goals, assists, getPoints(), gamesWon, gamesLost, getGamesPlayed());
return s;
}
public String getData() {
return String.format("%s %d %d %d %d", name, goals, assists, gamesWon, gamesLost);
}
public boolean equals(Object o) {
HockeyPlayer p = (HockeyPlayer) o;
return this.name.equals(p.name);

BIN
HockeyStats.class Normal file

Binary file not shown.

View File

@@ -7,26 +7,48 @@ public class HockeyStats {
static StringTokenizer st;
public static void main(String[] args) throws Exception {
loadData("data.txt");
Scanner s = new Scanner(System.in);
boolean close = false;
while (true) {
showMenu();
int n = s.nextInt();
switch (n) {
case 1:
loadData("data.txt");
break;
case 2:
showDataMenu();
int k = s.nextInt();
switch (k) {
case 1:
System.out.println(players.toString());
case 2:
saveData("save.txt");
case 3:
break;
case 4:
break;
default:
System.out.println("Please choose one of the available menu options!");
break;
}
break;
case 3:
showStatsMenu();
int t = s.nextInt();
switch (t) {
default:
break;
}
break;
case 4:
break;
System.out.println("Thank you!");
System.exit(0);
default:
System.out.println("Please choose one of the available menu options!");
continue;
}
break;
if (close) break;
}
s.close();
}
@@ -35,6 +57,17 @@ public class HockeyStats {
File f = new File(fileName);
br = new BufferedReader(new FileReader(f));
st = new StringTokenizer(br.readLine());
int n = Integer.parseInt(st.nextToken());
for (int i = 0; i < n; i++) {
st = new StringTokenizer(br.readLine());
players.addPlayer(
new HockeyPlayer(
st.nextToken() + " " + st.nextToken(), // first + last name
Integer.parseInt(st.nextToken()), // goals
Integer.parseInt(st.nextToken()), // assists
Integer.parseInt(st.nextToken()), // gamesWon
Integer.parseInt(st.nextToken()))); // gamesLost
}
}
public static void saveData(String fileName) throws Exception {
@@ -49,6 +82,7 @@ public class HockeyStats {
"""
<---------------------------->
Hockey Stats Manager Menu
Select an option:
(1) Load Data from Files
@@ -59,4 +93,23 @@ public class HockeyStats {
<---------------------------->
""");
}
public static void showDataMenu() {
System.out.print(
"""
<---------------------------->
Hockey Data Editor Menu
Select an option:
(1) Print Data
(2) Save Data
(3) null
(4) Quit
<---------------------------->
""");
}
public static void showStatsMenu() {}
}

BIN
PlayerList.class Normal file

Binary file not shown.

View File

@@ -26,7 +26,7 @@ public class PlayerList {
public String createSaveData() {
String s = pList.size() + "\n";
for (HockeyPlayer p : pList) {
s += p.name + p.goals + p.assists + p.gamesWon + p.gamesLost + "\n";
s += p.getData();
}
return s;
}

View File

@@ -0,0 +1,2 @@
1
Connor McDavid 9 8 7 6

2
save.txt Normal file
View File

@@ -0,0 +1,2 @@
1
Connor McDavid 9 8 7 6