2014 FRQ 1

// Part A
public static String scrambleWord(String word){
    String scrambled = "";

    for(int i = 1; i < word.length(); i++){
        word.substring(i-1,i+1);
        if(word.substring(i-1, i).equals("A") && !word.substring(i, i+1).equals("A")){
            scrambled += word.substring(i, i+1);
            scrambled += word.substring(i-1, i);
            i++;
        } else{
            scrambled += word.substring(i-1, i);
            if(i == word.length() - 1){
                scrambled += word.substring(i, i+1);
            }
        }

    }

    
    return scrambled;
}

System.out.println(scrambleWord("EGGS"));
EGGS
// Part B
public static void scrambleOrRemove(String[] wordList){
    ArrayList<String> newList = new ArrayList<>();
    
    for(String word : wordList){
        if(!scrambleWord(word).equals(word)){
            newList.add(word);
        }
        else{}
    }

    System.out.println(newList);
}

String wordList[] = {"TAN", "ABRACADABARA", "WHOA", "APPLE", "EGGS"};
scrambleOrRemove(wordList);
[TAN, ABRACADABARA, APPLE]

2014 FRQ 2

public class Director extends Rock { //copied from college board since we dnt have grid any more
    public Director(){
        super(Color.RED);
    }

    public void act(){
        if(getColor().equals(Color.GREEEN)){
            ArrayList<Actor> neighbors = getGRid(.getNeighbors(getLocation()));
            for(Actor actor:neighbors){
                actor.setDirection(actor.getDirection() + Location.RIGHT)
            }
            setColor(Color.RED)
        }
        else{
            setColor(Color.GREEN);
        }
    }
}

2014 FRQ 3

public class Student{
    private String name;
    private int absenceCount;

    public Student(String name, int absenceCount){
        this.name = name;
        this.absenceCount = absenceCount;
    }

    public String getName(){
        return this.name;
    }

    public int getAbsenceCount(){
        return this.absenceCount;
    }
}

public class SeatingChart {
    private Student[][] seats;
    public SeatingChart(List<Student> studentList, int rows, int cols){
        seats = new Student[rows][cols];
        
        int studentCount = 0;

        for(int i = 0; i < seats[0].length; i++){
            for(int j = 0; j < seats.length; j++){
                if(studentCount < studentList.size()){
                    seats[j][i] = studentList.get(studentCount);
                    studentCount++;
                } else {
                    seats[j][i] = null;
                }
                
            }
        }
    }

    public int removeAbsentStudents(int allowedAbsences){
        int count = 0;
        for(int i = 0; i < seats[0].length; i++){
            for(int j = 0; j < seats.length; j++){
                if(seats[j][i] == null){
                    continue;
                }
                if(seats[j][i].getAbsenceCount() > allowedAbsences){
                    seats[j][i] = null;
                    count++;
                }
            }
        }

        System.out.println("------------------");
        this.print();
        return count;
    }


    public void print(){
        for(Student[] students : this.seats){
            for(Student student : students){
                if(student != null){
                    System.out.print(student.getName() + " ");
                } else {
                    System.out.print("null ");
                }
            }

            System.out.println();
        }
    }
}

List<Student> studentList = new ArrayList<>();
studentList.add(new Student("Karen", 3));
studentList.add(new Student("Liz", 1));
studentList.add(new Student("Paul", 1));
studentList.add(new Student("Lester", 1));
studentList.add(new Student("Henry", 5));
studentList.add(new Student("Renee", 9));
studentList.add(new Student("Glen", 2));
studentList.add(new Student("Fran", 6));
studentList.add(new Student("David", 1));
studentList.add(new Student("Danny", 3));

SeatingChart seatingChart = new SeatingChart(studentList, 3, 4);

seatingChart.print();

seatingChart.removeAbsentStudents(4);
Karen Lester Glen Danny 
Liz Henry Fran null 
Paul Renee David null 
------------------
Karen Lester Glen Danny 
Liz null null null 
Paul null David null 
3

FRQ 4

public interface MenuItem {
    public String getName();

    public double getPrice();
}

public class Sandwich implements MenuItem{ String name;
    double price;
    
    public Sandwich(String name, double price){
        this.name = name;
        this.price = price;
    }

    @Override
    public String getName(){
        return this.name;
    }

    @Override
    public double getPrice(){
        return this.price;
    }
}

public class Salad implements MenuItem{
    String name;
    double price;
    
    public Salad(String name, double price){
        this.name = name;
        this.price = price;
    }
    
    @Override
    public String getName(){
        return this.name;
    }

    @Override
    public double getPrice(){
        return this.price;
    }
}

public class Drink implements MenuItem{
    String name;
    double price;
    
    public Drink(String name, double price){
        this.name = name;
        this.price = price;
    }
    
    @Override
    public String getName(){
        return this.name;
    }

    @Override
    public double getPrice(){
        return this.price;
    }
}

public class Trio implements MenuItem {
    Sandwich sandwich;
    Salad salad;
    Drink drink;

    String name;
    double price;

    public Trio(Sandwich sandwich, Salad salad, Drink drink){
        this.sandwich = sandwich;
        this.salad = salad;
        this.drink = drink;

        double total = 0;
        String string = "";
        if(this.sandwich.getPrice() >= this.salad.getPrice() && this.sandwich.getPrice() >= drink.getPrice()){
            if(this.salad.getPrice() >= drink.getPrice()){
                total += sandwich.getPrice() + salad.getPrice();
                string += this.sandwich.getName() + "/" + this.salad.getName() + " Trio";
            } else {
                total += sandwich.getPrice() + drink.getPrice();
                string += this.sandwich.getName() + "/" + this.drink.getName() + " Trio";
            }   
        } else if(this.drink.getPrice() >= this.sandwich.getPrice() && this.drink.getPrice() >= salad.getPrice()){
            if(this.salad.getPrice() >= sandwich.getPrice()){
                total += drink.getPrice() + salad.getPrice();
                string += this.drink.getName() + "/" + this.salad.getName() + " Trio";
            } else {
                total += drink.getPrice() + sandwich.getPrice();
                string += this.drink.getName() + "/" + this.sandwich.getName() + " Trio";
            }
        } else {
            if(this.drink.getPrice() >= sandwich.getPrice()){
                total += salad.getPrice() + drink.getPrice();
                string += this.drink.getName() + "/" + this.sandwich.getName() + " Trio";
            } else {
                total += salad.getPrice() + sandwich.getPrice();
                string += this.salad.getName() + "/" + this.sandwich.getName() + " Trio";
            }
        }

        this.price = total;
        this.name = string;
        
    }

    @Override
    public String getName(){
        return this.name;
    }

    @Override
    public double getPrice(){
        return this.price;
    }

    public static void tester(String[] args){
        Trio trio1 = new Trio(new Sandwich("Cheeseburger", 2.75), new Salad("Spinach Salad", 1.25), new Drink("Orange Soda", 1.25)); 
        Trio trio2 = new Trio(new Sandwich("Cheeseburger", 2.75), new Salad("Coleslaw", 1.25), new Drink("Cappuccino", 3.50)); 
        Trio trio3 = new Trio(new Sandwich("Club Sandwich", 2.75), new Salad("Spinach Salad", 1.25), new Drink("Orange Soda", 1.25)); 
        System.out.println(trio1.getName());
        System.out.println(trio1.getPrice());
        System.out.println(trio2.getName());
        System.out.println(trio2.getPrice());
        System.out.println(trio3.getName());
        System.out.println(trio3.getPrice());
    }
}

Trio.tester(null);
Cheeseburger/Spinach Salad Trio
4.0
Cappuccino/Cheeseburger Trio
6.25
Club Sandwich/Spinach Salad Trio
4.0

Notes:

Misread problem, just combine all the names, get better at reading lol

For if statements checking for conditions, think of how many conditions there are (total outcomes) and make if statements accordingly. 3 outcomes = 3 if statements only. Helps for simplification.

2006 FRQ 1

// part a
public boolean conflictsWith(Appointment other){
    if(other.getTime().overlapsWith(this.getTime())){
        return true;
    }
    return false;
}

// part b
public void clearConflicts(Appointment appt){
    for (int i = 0; i< apptList.size(); i++) {
        if (appt.conflictsWith((Appointment) apptList.get(i))) { // cast
            apptList.remove(i);
        }
    }
}

// part c
public boolean addAppt(Appointment appt, boolean emergency) {
    if (emergency) {
        clearConflicts(appt);
        this.apptList.add(appt);
        return true;
    } else{
        if(!conflictsWith(appt)) { // loop through conflicts
            this.apptList.add(appt);
            return true
        }
    }
    return false;
}