huge update idk
This commit is contained in:
BIN
HockeyPlayer.class
Normal file
BIN
HockeyPlayer.class
Normal file
Binary file not shown.
@@ -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
BIN
HockeyStats.class
Normal file
Binary file not shown.
@@ -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:
|
||||
break;
|
||||
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:
|
||||
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
BIN
PlayerList.class
Normal file
Binary file not shown.
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user