Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import greenfoot.*;
- public class CShark extends CInterFish
- {
- //deklaracia
- private CFish Meal;
- public CShark(CFish meal, int size)
- {
- super(size); //volania konstruktora pre size
- this.getImage().scale(size * 8, size * 6); //natstavenie rozmerov zraloka
- this.Meal = meal;
- this.Size = size;
- }
- public void act()
- {
- //ziskanie suradnic
- int FishX = this.Meal.getX();
- int FishY = this.Meal. getY();
- //otacanie za rybou
- this.turnTowards(FishX, FishY);
- this.move(1);
- }
- //metoda sa vola v triede CFish
- public void InteractWithFish(CFish fish)
- {
- //ak sa dotkne ryby
- this.Size++; // zvacsi svoju velkost o 1
- this.getImage().scale(this.Size * 8, this.Size * 6);//aktualizacia velkosti
- fish.Reset(); //natstavenie povodnych suradnic ryby
- //metoda je v triede CFish
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement