Advertisement
Filipinex

CTrash

Mar 19th, 2024
472
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.73 KB | None | 0 0
  1. import greenfoot.*;
  2.  
  3. public abstract class CTrash extends Actor
  4. {  
  5.     //deklaracia
  6.     protected int Weight;
  7.    
  8.     public CTrash(int weight) //odpad ma nejaku hmotnost na zaklade
  9.     {
  10.         this.Weight = weight; //ktorej sa urcuje rychlost padania
  11.         this.setRotation(90); //otocenie aby to bolo krajsie
  12.     }
  13.    
  14.     public void act()
  15.     {
  16.         Initialize(); // "inicializacia"
  17.     }
  18.    
  19.     public void Initialize()
  20.     {
  21.         this.move(this.Weight);  //bude sa hybat na zaklade svojej hmotnosti
  22.        
  23.         if (this.isAtEdge()) //ak sa dotkne steny
  24.         {
  25.             this.getWorld().removeObject(this);//zmizne
  26.         }
  27.     }
  28.    
  29.     public abstract void ApplyOnFish(CFish fish);
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement