FRQ 2011 Post
FRQ 2011 blog post for AP CSA
public class Level {
public boolean goalReached() {
}
public int getPoints() {
}
}
public class Game {
private Level levelOne;
private Level levelTwo;
private Level levelThree;
public Game() {
}
public boolean isBonus() {
}
public void play() {
}
public int getScore() {
int score = 0;
if (levelOne.goalReached() == true) {
score += levelOne.getPoints();
if (levelTwo.goalReached() == true) {
score += levelTwo.getPoints();
if (levelThree.goalReached() == true) {
score += levelThree.getPoints();
}
}
}
if (isBonus() == true) {
score *= 3;
}
return score;
}
public int playManyTimes(int num) {
int[] scores = new int[num];
int index = 0;
for (int i = 0; i < num; i++) {
play();
scores[index] = getScore();
index++;
}
int high = scores[0];
for (int j = 0; j < scores.length; j++) {
if (scores[j] > high) {
high = scores[j];
}
}
return high;
}
}
public class Book {
private String title;
private double price;
public Book() {
}
}
public class Textbook extends Book {
private int edition;
public Textbook(String bookTitle, double bookPrice, int editionNumber) {
super(bookTitle, bookPrice);
edition = editionNumber;
}
public String getBookInfo() {
return title + "-" + price + "-" + edition;
}
public int getEdition() {
return edition;
}
public boolean canSubstituteFor(Textbook previousTextbook) {
if (title.equals(previousTextbook.getTitle()) && edition >= previousTextbook.getEdition()) {
return true;
}
return false;
}
}
public class ReviewAnalysis {
private Review[] allReviews;
public ReviewAnalysis() {
}
public double getAverageRating() {
double average = 0;
for (Review review : allReviews) {
average += review.getRating();
}
average /= (double) review.length;
return average;
}
public ArrayList<String> collectComments() {
ArrayList<String> comments = new ArrayList<String>();
for (int i = 0; i < allReviews.length; i++) {
String finalString = "";
String comment = allReviews[i].getComment();
if (comment.contains("!") == true) {
finalString += i + "-" + comment;
if (comment.substring(comment.length() - 1).equals("!") || comment.substring(comment.length() - 1).equals(".")) {
}
}
}
}
}