-
Notifications
You must be signed in to change notification settings - Fork 0
/
Game.java
59 lines (47 loc) · 1.3 KB
/
Game.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
public class Game {
//private instance variables
private String date;
private String gameType;
private String winner;
//constructors
public Game() {
date = "0000-00-00";
gameType = "default";
winner = "default name";
}
public Game(String date, String gameType, String winner) {
this.date = date;
this.gameType = gameType;
this.winner = winner;
}
//getter and setter methods
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public String getGameType() {
return gameType;
}
public void setGameType(String gameType) {
this.gameType = gameType;
}
public String getWinner() {
return winner;
}
public void setWinner(String winner) {
this.winner = winner;
}
//toString methods
public String toString() {
return "Date: " + date.substring(5, 7) + "/" + date.substring(8) + "/" + date.substring(0, 4) +
" Game: " + gameType + " Winner: " + winner;
}
public String toStringDateFormatted() {
return date.substring(5, 7) + "/" + date.substring(8) + "/" + date.substring(0, 4);
}
public String toStringTextFile() {
return date + "," + gameType + "," + winner;
}
}