Monday, November 8, 2010

Exam #3 is November 22nd

Exam #3 is Monday, November 22nd, covering Chapters 5-10.

One more minor change to Assignment 9

Be sure to initialize your energy to 0 when you create your CollegeStudent.

Change to Assignment 9

A very small change has been made to the cram method. It now has the student drink a mountain dew before studying, then repeat until out of energy. Finally the student will sleep. The API has been updated accordingly.

Friday, October 22, 2010

Modification to Assignment #8

We have made a couple of modifications to Assignment #8 in order to simplify it somewhat. The assignment webpage has been updated. In a nutshell, the changes are for you to create a second constructor that has 3 parameters to create a specified date. You are no longer required to write methods for setMonth(), setDay(), and setYear(). You also do not need to write methods for nextMonth() and nextYear(). Finally, we are permitting you to use precise English instead of formal Java boolean expressions for your complex preconditions and postconditions. We will clarify this further in class on Monday, but don't wait to start working on the assignment.

Thursday, October 21, 2010

Sample solution for last question of Exam #2


package iamhungry;

/**
* This class models a college student.
*/
public class CollegeStudent {

private String name;
private int favoritePizzaTopping;
private int pizzasBaked;

/**
* This constructor creates a college student with a given name
* and a favorite pizza topping. The student has not yet baked
* any pizzas.
*/
public CollegeStudent (String name, int favoritePizzaTopping) {
this.name = name;
this.favoritePizzaTopping = favoritePizzaTopping;
this.pizzasBaked = 0;
}

/**
* This method commands the student to bake the pizza being
* passed in.
*/
public void bakePizza (FrozenPizza fp) {
fp.bake(425, 10);
pizzasBaked = pizzasBaked + 1;
}

/**
* This method checks if the given pizza has the tuype of topping
* that is the student's favorite.
*/
public boolean checkForPreferredPizza (FrozenPizza fp) {
return fp.topping() == favoritePizzaTopping;
}

/**
* This method classifies the student according to the number of
* pizzas they have baked. Less than 10 is a "taster" 10 - 20 is
* an enthusiast. Over 20 is a "connoisseur".
*/
public String classification () {
if (pizzasBaked < 10) {
return "taster";
}
else if (pizzasBaked <= 20) {
return "enthusiast";
}
else {
return "connoisseur";
}
}
}

Test 2 - last question

I was just wondering if you guys were going to post a solution to the last question of Test 2.

Thanks,
Josh

Monday, October 18, 2010

Assignment #7 extended until October 19th at 11:59pm

Just a reminder that we are giving you until tomorrow night (Tuesday, October 19) at 11:59pm to redo Assignment #7 and turn it in again.