Advertisement
Filipinex

CShark

Mar 19th, 2024
408
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.99 KB | None | 0 0
  1. import greenfoot.*;
  2.  
  3. public class CShark extends CInterFish
  4. {
  5.     //deklaracia
  6.     private CFish Meal;
  7.    
  8.     public CShark(CFish meal, int size)
  9.     {
  10.         super(size); //volania konstruktora pre size
  11.         this.getImage().scale(size * 8, size * 6); //natstavenie rozmerov zraloka
  12.         this.Meal = meal;
  13.         this.Size = size;
  14.     }
  15.    
  16.     public void act()
  17.     {
  18.         //ziskanie suradnic
  19.         int FishX = this.Meal.getX();
  20.         int FishY = this.Meal. getY();
  21.        
  22.         //otacanie za rybou
  23.         this.turnTowards(FishX, FishY);
  24.         this.move(1);
  25.        
  26.        
  27.        
  28.     }
  29.    
  30.     //metoda sa vola v triede CFish
  31.     public void InteractWithFish(CFish fish)
  32.     {
  33.         //ak sa dotkne ryby
  34.         this.Size++; // zvacsi svoju velkost o 1
  35.         this.getImage().scale(this.Size * 8, this.Size * 6);//aktualizacia velkosti
  36.         fish.Reset(); //natstavenie povodnych suradnic ryby
  37.         //metoda je v triede CFish
  38.     }
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement