-
Notifications
You must be signed in to change notification settings - Fork 0
/
Player.java
120 lines (97 loc) · 3.01 KB
/
Player.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
// functionality: limited, mostly just housing ELO scores right now
package thesis;
/**
*
* @author natha_000
*/
public class Player implements Comparable<Player> {
private int ELOscore;
private int originalELOscore;
private String firstName, lastName;
private char handedness;
private boolean isBetOn;
// other characteristics: age, former top 10 status, court, MATCH HISTORY
public Player (int Escore, String first, String last){
this.ELOscore = Escore;
this.originalELOscore = Escore;
this.firstName = first;
this.lastName = last;
}
public Player(int EScore, String first, String last, char hand){
this.ELOscore = EScore;
this.originalELOscore = EScore;
this.firstName = first;
this.lastName = last;
this.handedness = hand;
}
public Player (int EScore){
this.ELOscore = EScore;
}
public void setELOscore (int newELO){
this.ELOscore = newELO;
}
public int getELOscore(){
return ELOscore;
}
public void setELOToOriginal(){
this.ELOscore = originalELOscore;
}
public void setName (String first, String last){
this.firstName = first;
this.lastName = last;
}
public String getName(){
return "" + this.firstName + " " + this.lastName;
}
public String getFirstName(){
return "" + this.firstName;
}
public String getLastName(){
return "" + this.lastName;
}
public void setHandedness (char h){
if (h == 'r'){
this.handedness = 'r';
} if (h == 'l'){
this.handedness = 'l';
} else System.out.println("Input 'l' for left, 'r' for right");
}
public char getHandedness(){
return this.handedness;
}
public void setBetOnStatus(boolean status){
this.isBetOn = status;
}
public boolean getBetOnStatus(){
return isBetOn;
}
@Override
public int compareTo(Player otherPlayer) {
return Integer.compare(otherPlayer.ELOscore, this.ELOscore);
}
@Override
public boolean equals(Object o){
if(o instanceof Player){
Player p = (Player) o;
return this.firstName.equals(p.getFirstName()) && this.lastName.equals(p.getLastName());
} else {
return false;
}
}
@Override
public int hashCode(){
int id = this.ELOscore;
id += this.firstName.length();
id += this.lastName.length();
return id;
}
@Override
public String toString(){
return this.firstName + " " + this.lastName + ", ELO Score: " + this.ELOscore + "\n";
}
}