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.
Friday, October 8, 2010
Constructor for ObjectiveC Card Class
-(id) initWithFrame:(CGRect) rect {
[super initWithFrame:rect];
self.backgroundColor = [UIColor whiteColor];
image= [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"blank.jpg"]] autorelease];
image.frame = CGRectMake(0, 0, 80, 110);
image.opaque = YES;
[self addSubview:image];
return self;
}
[super initWithFrame:rect];
self.backgroundColor = [UIColor whiteColor];
image= [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"blank.jpg"]] autorelease];
image.frame = CGRectMake(0, 0, 80, 110);
image.opaque = YES;
[self addSubview:image];
return self;
}
To Turn on Ensure and Require Tags in Dr Java
Go to Edit->Preferences. In custom Javadoc parameters, enter:
-author -version -tag require:cm:"Require:" -tag ensure:cm:"Ensure:"
-author -version -tag require:cm:"Require:" -tag ensure:cm:"Ensure:"
Tuesday, October 5, 2010
Assignment 6 Extension
There have been some questions on the requirements for assignment 6. We want to make sure all of the requirements are clear and take some time for questions tomorrow during class. Thus, we are extending the deadline for assignment 6 until Thursday (10/7) 11:59PM. Do note that assignment 7 is also posted and will be due next Tuesday (10/12).
Assignment 6 Additional Information
One additional note on the assignment due this evening. In the buyItem method in LittleTike, you should first check with Daddy to see if the LittleTike has enough money in their PiggyBank to buy an Item. If the LittleTike gets an affirmative response, you then should proceed to ask the Mommy to pleaseBuyItem. Do not ask Mommy to buy the item if Daddy indicates that there are insufficient funds in the PiggyBank.
Assignment 6: New File Available
A copy of the LittleTike.java which meets the requirements for assignment 5 is now available. If you did not successfully complete LittleTike for assignment 5, you can build off this version for assignment 6.
Subscribe to:
Comments (Atom)