-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTeam.java
More file actions
89 lines (71 loc) · 1.97 KB
/
Team.java
File metadata and controls
89 lines (71 loc) · 1.97 KB
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
import java.io.Serializable;
public class Team implements Serializable {
private static final long serialVersionUID = 1L;
private String name;
private int matchesPlayed;
private int wins;
private int losses;
private int draws;
private int points;
public Player[] players = new Player[11];
private double totalRunsScored = 0;
private double totalOversFaced = 0;
private double totalRunsConceded = 0;
private double totalOversBowled = 0;
public Team(String name) {
this.name = name;
this.matchesPlayed = 0;
this.wins = 0;
this.losses = 0;
this.draws = 0;
this.points = 0;
}
public String getName() {
return name;
}
public int getMatchesPlayed() {
return matchesPlayed;
}
public int getWins() {
return wins;
}
public int getLosses() {
return losses;
}
public int getdraws() {
return draws;
}
public int getPoints() {
return points;
}
// Match Increment Methods
public void incrementMatchesPlayed() {
matchesPlayed++;
}
public void incrementWins() {
wins++;
points += 2;
}
public void incrementLosses() {
losses++;
// 0 points for loss
}
public void incrementdraws() {
draws++;
points += 1;
}
public void updateStats(int runsScored, double oversFaced, int runsConceded, double oversBowled) {
this.totalRunsScored += runsScored;
this.totalOversFaced += oversFaced;
this.totalRunsConceded += runsConceded;
this.totalOversBowled += oversBowled;
}
public double getNRR() {
double runRateFor = totalOversFaced > 0 ? totalRunsScored / totalOversFaced : 0;
double runRateAgainst = totalOversBowled > 0 ? totalRunsConceded / totalOversBowled : 0;
return runRateFor - runRateAgainst;
}
public Player[] getPlayers() {
return players;
}
}