import java.util.*; /** * * @author Divine */ public class Player implements Comparable{ public static final int DEFAULT = 0; private String Name; private int Kills; private int Assists; private int Deaths; public Player(String Name, int Kills, int Assists, int Deaths) { this.Name = Name; this.Kills = Kills; this.Assists = Assists; this.Deaths = Deaths; } public Player(String Name) { this(Name, DEFAULT, DEFAULT, DEFAULT); } /*Getter's*/ public String getName() { return Name; } public int getKills() { return Kills; } public int getAssists() { return Assists; } public int getDeaths() { return Deaths; } /*Setters*/ public void addKills(int addKills) { Kills += addKills; } public void addAssists(int addAssists) { Assists += addAssists; } public void addDeaths(int addDeaths) { Deaths += addDeaths; } public String toString() { return Name + ", " + Kills + ", " + Assists + ", " + Deaths; } /*Organized for Descending order*/ public int compareTo(Player other) { double mKD = this.getKills() / (double) this.getDeaths(); double oKD = other.getKills() / (double) other.getDeaths(); if (this.getKills() > other.getKills() /*mKD > oKD*/) { return -1; } else if(this.getKills() < other.getKills() /*mKD < oKD*/) { return 1; } else { if(this.getDeaths() != other.getDeaths()) { if(this.getDeaths() > other.getDeaths()) { return 1; } else { return -1; } } else if(this.getAssists() != other.getAssists()) { if(this.getAssists() > other.getAssists()) { return -1; } else { return 1; } } else{ /*System.out.println("Your CompareTo method is insufficient");*/ Random rand = new Random(); int rng = rand.nextInt(2); rng = -1 + 2 * rng; if(rng == 0) { //System.exit(-1); } else { return rng; } } } System.out.println("panic 2 players are equal"); return 0; } }