Advertisement
Guest User

Untitled

a guest
Apr 21st, 2014
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.91 KB | None | 0 0
  1. package jagirm;
  2.  
  3. import textgame.Item;
  4.  
  5. /**
  6.  * Aspekt sluzi na mazanie/vkladanie predmetov v miestnosti po ich vzati/polozeni.
  7.  *
  8.  */
  9. public aspect RoomItemsAspect {
  10.    
  11.     Item temp;
  12.     GameImpl game;
  13.  
  14.     after(GameImpl g): initialization(GameImpl.new(..))&&target(g){
  15.         game=g;
  16.     }
  17.    
  18.     pointcut addItem(String item) : execution(* BackpackImpl.remove(..)) && args(item);
  19.    
  20.     pointcut removeItem(Item item, RoomImpl r) : execution(* BackpackImpl.add(..)) && args(item) && this(r);
  21.    
  22.     before(String item) : addItem(item) {
  23.         temp = game.getBackpack().getItem(item);
  24.     }
  25.    
  26.     after(String item) : addItem(item) {
  27.         game.getCurrentRoom().addItem(temp);
  28.         System.out.println("Pridal si do miestnosti predmet s nazvom " + item + ".");
  29.     }
  30.    
  31.     before(Item item, RoomImpl r) : removeItem(item, r) {
  32.         r.removeItem(item);
  33.         System.out.println("Odstranil si z miestnosti predmet s nazvom " + item.getName() + ".");
  34.  
  35.     }
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement