College Board Units HW
List of all unit HWs
HW Scores
Unit | Score | Comments |
---|---|---|
Unit 1 Primitives | 1/1 | Took lots of notes and did extra problems |
Unit 2 Using Objects | 0.9/1 | :thumbs up: |
Unit 3 Booleans, If/Else | 0.9/1 | no comment |
Unit 4 Iteration | 1/1 | no comment |
Unit 5 Classes | N/A | (own lesson so no grade) |
total | 3.8/4 |
// 2006 1a
public boolean conflictsWith(Appointment other){
return getTime().overlapsWith(other.getTime());
}
// 2006 1b
public void clearConflicts(Appointment appt){
for (int i = 0; i < aptList.size(); i++){
if (appt.conflictsWith((Appointment)apptList.get(i))){
aptList.remove(i);
}
}
}
// 2006 1c
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);
}
// 2006 2a
public double purchasePrice(){
return (1 + taxRate) * getListPrice();
}
// 2006 3a
public int compareCustomer(Customer other){
int comparedNames = getName().compareTo(other.getName());
if (comparedNames != 0){
return comparedNames;
}
else{
return getID() - other.getID();
}
}
public class Goblin {
private String name;
private int HP;
private int DMG;
private double hitChance;
private double criticalHitChance;
public String getName() {
return name;
}
public int getHP() {
return HP;
}
public int getDMG() {
return DMG;
}
public double getHitChance() {
return hitChance;
}
public double getCriticalHitChance(){
return criticalHitChance;
}
public boolean isAlive() {
if (this.HP > 0) {
return true;
} else {
return false;
}
}
public void setName(String newName) {
this.name = newName;
}
public void setHP(int newHP) {
this.HP = newHP;
}
public void takeDMG(int takenDamage) {
this.HP -= takenDamage;
}
public void setDMG(int newDMG) {
this.DMG = newDMG;
}
public void setHitChance(double newHitChance) {
this.hitChance = newHitChance;
}
public void setCriticalHitChance(double newCriticalHitChance) {
this.criticalHitChance = newCriticalHitChance;
}
}
// 2009 3b
public int getChargeStartTime(int chargeTime){
int startTime = 0;
for (int i = 1; i < 24; i++){
if (this.getChargingCost(i, chargeTime) < this.getChargingCost(startTime, chargeTime)){
startTime = i;
}
}
return startTime;
}
// 2017 1b
public boolean isStrictlyIncreasing(){
for (int i = 0; i < digitList.size()-1; i++){
if (digitList.get(i).intValue() >= digitList.get(i+1).intValue()){
return false;
}
}
return true;
}
// 2019 3b
public boolean evaluateLight(int row, int col) {
int onInCol = 0;
for (int r = 0; r < lights.length; r++) {
if (lights[r][col]) {
onInCol++;
}
}
if (lights[row][col] && onInCol % 2 == 0) {
return false;
} else if (!lights[row][col] && onInCol % 3 == 0) {
return true;
} else {
return lights[row][col];
}
}
public class Guessing {
static int b = randomNumber();
static boolean gameRunning = true;
public static int randomNumber() {
double a = (1 + Math.random() * 100);
return ((int) Math.floor(a));
}
public static void newNumber(){
b = randomNumber();
}
public static String guessing(String guess) {
int c = Integer.valueOf(guess);
if (c != b) {
if (c > b) {
return (c + " was not the number," + "\nlower\n");
}
if (c < b) {
return ( c + " was not the number," + "\nhigher\n");
}
}
if (c == b) {
gameRunning = false;
return "You guessed it! The number was " + b;
}
return "error";
}
}
public class Main{
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
while(Guessing.gameRunning){
System.out.println("Type Guess Here: ");
String input = scanner.nextLine();
System.out.println(Guessing.guessing(input));
}
}
}
Main.main(null);