Java

OOP GUIDE / WORK

 

MULTPRACTICE CLASS SOLUTIONS

 

Source

  • This question was part of the 2017 AP exam free response questions.  You can find a link to all free response questions on the previous page.

 

 

TASK – PART 1 – SETUP – STUDYPRACTICE INTERFACE

 

No solution required.

 

 

TASK – PART 2 – WORK

 

Here is my solution:

 

 

public class MultPractice implements StudyPractice

{

     private int first;

     private int second;

    

     public MultPractice(int f, int s)

     {

           first = f;

           second = s;

     }

 

     @Override

     public String getProblem()

     {

           return first + " TIMES " + second;

     }

 

     @Override

     public void nextProblem()

     {

           second++;

     }

}

 

 

 

TASK – PART 3 – TESTING YOUR CLASS

 

No solution required.