forked from get-flord/Project2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClanWins.java
More file actions
executable file
·65 lines (58 loc) · 1.72 KB
/
ClanWins.java
File metadata and controls
executable file
·65 lines (58 loc) · 1.72 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
package clanmelee;
/**
* This class creates one clan with its name
* and initializes the clans number of wins
* to zero
*/
public class ClanWins implements Comparable<ClanWins> {
private String name;
private Integer wins;
/**
* Constructor to create a class with the clan name as a parameter
* which initializes the number of wins to zero.
*
* @param String name - the desired name of the clan being created
*/
public ClanWins(String name) {
this.name = name;
this.wins = 0;
}
/**
* Adds one win to the number of wins for a clan
*/
public void addWin() {
wins += 1;
}
/**
* Getter method to get the name of the clan.
*
* @return string name - the name of the clan
*/
public String getName() {
return name;
}
/**
* Getter method to get the number of wins that a clan has.
*
* @return int wins - number of wins that particular clan has
*/
public int getWins() {
return wins;
}
/**
* Comparison method to compare clans according to the number of wins
* each one has.
* CompareTo returns -1 if this.clan has less wins than other.clan
* CompareTo returns 0 if this.clan has equal wins as other.clan
* CompareTo returns 1 if this.clan has more wins than other.clan
*
* @param ClanWins other - the clan that the current clan is being compared to
* @return int -1 if this.clan.wins > other.clan.wins
* int 0 if this.clan.wins = other.clan.wins
* int 1 if this.clan.wins < other.clan.wins
*/
@Override
public int compareTo(ClanWins other) {
return wins.compareTo(other.getWins()) * -1;
}
}