Не могу понять, как получить доступ к методу getScore () из класса RatingCalculator и как получить доступ к переопределенному методу addPoints () из класса CalculatorForBoxing.
public class Calculator {
class Score{
int score;
int playerId;
}
class RatingCalculator extends Score {
ArrayList<CalculatorForBoxing> newGame;
public CalculatorForBoxing boxer1;
public CalculatorForBoxing boxer2;
ArrayList<Integer> getScores(){
return myArrayList;
}
}
Вот калькулятор для конкретного вида спорта
class CalculatorForBoxing extends RatingCalculator implements RateByAccumulatingPoints {
int forbiddenKicks;
int successfullKicks;
public CalculatorForBoxing (int playerId, int score, int forbiddenKicks, int successfullKicks ) {
this.playerId = playerId;
this.score = score;
this.forbiddenKicks = forbiddenKicks;
this.successfullKicks = successfullKicks;
}
public void setPlayerId(int playerId) {
this.playerId = playerId;
}
public int getPlayerId() {
return playerId;
}
public void setScore(int score) {
this.score = score;
}
public int getScore() {
return score;
}
@Override
public void addPoints(int playerId, int points) {
//some code
}
}
interface RateByAccumulatingPoints {
void addPoints(int playerId, int points );
}
здесь мне нужно продемонстрировать, как работают калькуляторы для разных видов спорта
class Judge extends RatingCalculator {
// here my simple scenario;
void rate(RatingCalculator rc){
newGame = new ArrayList<CalculatorForBoxing>();
newGame.add(boxer1 = new CalculatorForBoxing(01, 0, 0, 4));
newGame.add(boxer2 = new CalculatorForBoxing(02, 0, 0, 5));
newGame.addPoints(01, 20); //haven't access here
newGame.getScores(); //haven't access here
}
}