2006 FRQ #1

public boolean conflictsWith (Appointment other) {
    return getTime().overlapsWith(other.getTime());
}
int x = 0;
public void clearConflicts (Appointment appt) {
    while (x < apptList.size()) {
        if (appt.conflictsWith((Appointment) (apptList.get(x)))) {
            apptList.remove(x);
        }
        else {
            x++;
        }
    }
}
public boolean addAppt(Appointment appt, boolean emergency) {
    if (emergency) {
        clearConflicts(appt);
    }
    else {
        for (int i = 0; i < apptList.size(); i++) {
            if (appt.conflictsWith((Appointment)apptList.get(i))) {
                return false;
            }
        }
    }
 return apptList.add(appt);
public double purchasePrice() {
    return (1 + taxRate) * getListPrice();
}
public int compareCustomer(Customer other) {
    int nameCompare = getName().compareTo(other.getName());
    if (nameCompare != 0) {
        return nameCompare;
    }
    else {
        return getID() - other.getID();
    }
}

Goblins HW

public RandomGoblin extends goblin { 

    public RandomGoblin () {
       this.hitPower = Math.random();
    
    }
}
import java.lang.Math;

public class Duel {

    public static void attack(Goblin attackerGoblin, Goblin attackeeGoblin) {

        System.out.println(attackerGoblin.getName() + " attacks " + attackeeGoblin.getName() + "!");
        if (Math.random() < attackerGoblin.getHitChance()) {
            attackeeGoblin.takeDMG(attackerGoblin.getDMG());
            System.out.println(attackerGoblin.getName() + " hits!");
            System.out.println(attackeeGoblin.getName() + " takes " + attackerGoblin.getDMG() + " damage");
        } else {
            System.out.println(attackerGoblin.getName() + " misses...");
        }

        System.out.println(attackeeGoblin.getName() + " HP: " + attackeeGoblin.getHP());
        System.out.println();
    }

    public static void fight(Goblin goblin1, Goblin goblin2) {
        while (goblin1.isAlive() && goblin2.isAlive()) {
            
            attack(goblin1, goblin2);

            if (!goblin1.isAlive()) {
                System.out.println(goblin1.getName() + " has perished");
                break;
            }

            attack(goblin2, goblin1);

            if (!goblin2.isAlive()) {
                System.out.println(goblin2.getName() + " has perished");
                break;
            }
        }
    }

    public static void main(String[] args) {
        Goblin goblin1 = new Goblin();
        goblin1.setName("jeffrey");
        goblin1.setHP(12);
        goblin1.setDMG(2);
        public RandomGoblin () {
            this.hitPower = Math.random();
         
        Goblin goblin2 = new Goblin();
        goblin2.setName("Gunther the great");
        goblin2.setHP(4);
        goblin2.setDMG(1);
        goblin2.setHitChance(1);

        fight(goblin1, goblin2);
    }
}

Duel.main(null);