The IAnswers
interface has the methods:
int numAnswers();
int getAnswer(int k);
The multiple choice answers class MCAnswers
implements the IAnswers
interface. Its constructor is:
public MCAnswers (int[] answers)
IAnswers
key of correct answers.int score(IAnswers student)
gives the score for the
remembered student answer sheet.int scoreOne(int correct, int given)
returns the
score for a single answer.IAnswers
key of correct answers.scoreOne
method is 4 points for a correct answer
and -1 point for a wrong answer. int[] ans = {2,2,1,3,4};
int[] student = {2,2,4,3,4};
IAnswers a = new MCAnswers(ans);
IAnswers s = new MCAnswers(student);
AQuiz b = new MCQuiz(a);
int result = b.score(s);
System.out.println(result); // prints 15 = +4 +4 -1 +4 +4