次のように抽象クラスを作成しました。
abstract class Chance
{
public void setTeams(SportEvent aSportEvent)
{
firstTeam = aSportEvent.getFirstTeam();
secondTeam = aSportEvent.getSecondTeam();
}
private int totalPlayedGames()
{
int playedAtHome = firstTeam.getHomePlayedGames();
int playedAway = secondTeam.getAwayPlayedGames();
int playedGames = playedAtHome + playedAway;
return playedGames;
}
private int totalScoredGoals()
{
int homeScoredGoals = firstTeam.getHomeScoredGoals();
int awayScoredGoals = secondTeam.getAwayScoredGoals();
int scoredGoals = homeScoredGoals + awayScoredGoals;
return scoredGoals;
}
abstract double getChance()
Team firstTeam;
Team secondTeam;
}
それからもちろん、私はメソッドを持ついくつかのクラスを持っていgetChance()
ます...
getChance()
ここで、これらの新しいクラスの結果を取得できるクラスを作成したいと考えました。私は次のようなものを使用することを考えました:
Class aClass = Class.forName(chanceClass....);
Object obj = aClass.newInstance();
そして今、「getChance()」メソッドを使用したいと思います。
どうすればいいですか?