question on overriding
Posted: Thu Sep 30, 2010 9:53 pm
Hi, for my second friendly monster, I made a class i called gnome. but I'm a little confused about the instruction to override the parent class. After some research, Ive done the following, which has the gnome do a different action than give gifts through the gift class, but I'm not certain that this is what was meant. I just wanted to knw if I was on the right track.
class Gnome extends FriendlyMonster {
PImage gnomeImg = loadImage("gnome.jpg");
public Gnome() {
super.gifts.add("the gnome wants to help you get a discount on your travel planning");
}
public void giveGifts() {
println(super.gifts);
}
public void render(int x, int y) {
super.render(x,y);
image(gnomeImg, x,y,w,h);
}
}
class Gnome extends FriendlyMonster {
PImage gnomeImg = loadImage("gnome.jpg");
public Gnome() {
super.gifts.add("the gnome wants to help you get a discount on your travel planning");
}
public void giveGifts() {
println(super.gifts);
}
public void render(int x, int y) {
super.render(x,y);
image(gnomeImg, x,y,w,h);
}
}