Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.78 KB | None | 0 0
  1. interface Quest {
  2.     void process();
  3. }
  4.  
  5. class DeadIslandQuest implements Quest{
  6.     public void process() {
  7.     System.out.println("Tekst pierwszy");  
  8.     }
  9. }
  10.  
  11. class EliteKnightQuest implements Quest{
  12.     public void process() {
  13.     System.out.println("Zakończenie zadania wraz z jego nazwą");  
  14.     }
  15. }
  16.  
  17. class Knight {
  18.  private Quest quest;
  19.    
  20.     public Knight(Quest quest) {
  21.         this.quest = quest;
  22.     }
  23.    
  24.     public void goOnQuest() {
  25.         this.quest.process();
  26.     }
  27.    
  28. }
  29.  
  30. class Application {
  31.      public static void main (String[] args) {
  32.        
  33.        Knight knight1 = new Knight(new EliteKnightQuest());
  34.        knight1.goOnQuest();
  35.        
  36.        Knight knight2 = new Knight(new DeadIslandQuest());
  37.        knight2.goOnQuest();
  38.    }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement