Introduction | 2023 FRQ | Hw/Review |
Classes
Team Teach for Classes
Conclusion (Jason)
The “Classes” section gives a simple guide to handling Classes FRQs in APCSA. It explains key ideas like writing class headers, constructors, and methods, and keeping instance variables private. Following these steps makes your code organized and clear, which helps earn points on the exam.
Tips
-
Follow Instructions: Always match class headers, constructors, and method details to what’s asked in the question.
-
Keep it Simple: Use
this.variable = parameter;
to set instance variables in constructors. -
Check Scoping: Class and method headers should usually be
public
, and instance variables should always beprivate
.
Homework! (Jason)
2017 FRQ, Question 2 - Classes
Homework over here…
HW
public class MultiplicationPractice implements StudyPractice {
private int multiplicand;
private int multiplier;
public MultiplicationPractice(int multiplicand, int multiplier) {
this.multiplicand = multiplicand;
this.multiplier = multiplier;
}
public String getProblem() {
return multiplicand + " TIMES " + multiplier;
}
public void nextProblem() {
multiplier++;
}
}
| public class MultPractice implements StudyPractice {
| private int firstInteger;
| private int secondInteger;
|
| public MultPractice(int firstInteger, int secondInteger) {
| this.firstInteger = firstInteger;
| this.secondInteger = secondInteger;
| }
|
|
| public String getProblem() {
| return firstInteger + " TIMES " + secondInteger;
| }
|
| public void nextProblem() {
| secondInteger++;
| }
| }
Unresolved dependencies:
- class StudyPractice