2017 FRQ Question 2 - Class Design
Gamified FRQ Quest: MultPractice Adventure
You are now a code hero in a game-like AP CSA challenge. Complete the mission by implementing MultPractice and earning stars.
Quest Briefing (FRQ Requirements)
Interface provided:
Code Runner Challenge
Implement MultPractice
View IPYNB Source
public interface StudyPractice {
String getProblem(); // Returns the current practice problem
void nextProblem(); // Advances to the next practice problem
}
Lines: 1
Characters: 0
Output
Click "Run" in code control panel to see output ...
Your class must:
- implement
StudyPractice - store two private ints:
firstInteger(constant),secondInteger(increments) getProblem()returns exact"x TIMES y"nextProblem()incrementssecondInteger
Game Levels (Practice Path)
- Level 1: Starter — Base class
- Build class with constructor and methods
- Get 10 XP
- Level 2: Mid-game — State behavior
- Ensure
nextProblem()changes output sequence - Get 15 XP
- Ensure
- Level 3: Boss encounter — Edge-case challenge
- Add optional
reset()orskip(int n)as bonus - Get 20 XP + unlock badge
- Add optional
Challenge Scoreboard
- 10 XP: Implement constructor + interface
- 15 XP:
getProblem()formatting accuracy - 15 XP:
nextProblem()state update - 20 XP: Add a bonus feature (reset/skip/validate)
Total available XP: 60 (40 baseline + 20 bonus)
// CODE_RUNNER: Implement MultPractice
interface StudyPractice {
String getProblem();
void nextProblem();
}
class MultPractice implements StudyPractice {
private int firstInteger;
private int secondInteger;
public MultPractice(int firstInteger, int initialSecondInteger) {
this.firstInteger = firstInteger;
this.secondInteger = initialSecondInteger;
}
public String getProblem() {
return firstInteger + " TIMES " + secondInteger;
}
public void nextProblem() {
secondInteger++;
}
// Bonus level: reset for extra XP
public void reset(int newSecond) {
secondInteger = newSecond;
}
}
public class Main {
public static void main(String[] args) {
MultPractice p = new MultPractice(7, 3);
System.out.println(p.getProblem()); // 7 TIMES 3
p.nextProblem();
System.out.println(p.getProblem()); // 7 TIMES 4
p.reset(100);
System.out.println(p.getProblem()); // 7 TIMES 100
}
}
Main.main(null);
Boss Validation (Automated Testing)
Run the code. Expected output exactly:
7 TIMES 37 TIMES 47 TIMES 100
If true, you defeat the boss and earn “Multiplicative Commander”.
Reward Tiers for Teachers
- Star 1: Base requirement passed
- Star 2: Sequence correctness
- Star 3: Bonus method implemented
- Star 4: Comments and narrative included
- Star 5: Reflection written
Reflection (Victory Screen)
- What part of
MultPracticefelt most like a game mechanic? - How does
nextProblem()compare to “advancing to next level”? - Suggest one extra feature to continue gamification (e.g.,
powerUp()that increments by 2).