-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTeam.java
46 lines (34 loc) · 936 Bytes
/
Team.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
public class Team {
private String name;
private int wins;
private int losses;
public void setName(String name) {
this.name = name;
}
public void setWins(int wins) {
this.wins = wins;
}
public void setLosses(int losses) {
this.losses = losses;
}
public String getName() {
return name;
}
public int getWins() {
return wins;
}
public int getLosses() {
return losses;
}
public double getWinPercentage() {
return (double) wins / (wins + losses);
}
public void printStanding() {
double winPercent = getWinPercentage();
System.out.printf("Win percentage: %,.2f\n", winPercent);
if (winPercent >= 0.5)
System.out.println("Congratulations, Team " + name + " has a winning average!");
else
System.out.println("Team " + name + " has a losing average.");
}
}