Select Git revision
Competitor.java
-
Mail Ladjali authoredMail Ladjali authored
Competitor.java 1.34 KiB
class Competitor{
private int score;
private int time;
private String numberSign;
public Competitor(int numberSign, int score, int min, int sec){
if(!verifierdossard(numberSign, score, min, sec)){
this.numberSign="invalide";
}
else{this.numberSign ="No"+ numberSign;
}
this.score = score;
this.time = 60*min + sec;
}
public String toString(){
return "(" + this.numberSign + ", " + this.score + " points, " + this.time + "s)";
}
public static boolean verifierdossard(int numberSign, int score, int min, int sec){
if(numberSign <1 || numberSign >100){
return false;
} else if(score <0 || score >50){
return false;
} else if (min <0 || min >59){
return false;
} else if (sec <0 || sec >59){
return false;
}return true;
}
public boolean equals(Competitor other){
if(this==other){
return true;
}else if(other==null){
return false;
}else if(this.numberSign.equals (other.numberSign) && this.score==other.score){
return true;
} return false;
}
public boolean isFaster(Competitor other){
if(this.time > other.time){
return false;
} return true;
}
}