Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2017
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.18 KB | None | 0 0
  1. public class Gegner
  2. {
  3.     private int x;
  4.     private int y;
  5.     private int anzahl_Pfeile;
  6.     private Rucksack rucksack;
  7.    
  8.     public Gegner(int x, int y){
  9.         this.x = x;
  10.         this.y = y;
  11.         anzahl_Pfeile = 10;
  12.         rucksack = new Rucksack(2,2);
  13.     }
  14.    
  15.     public void setX(int x){
  16.         this.x = x;
  17.     }
  18.    
  19.     public int getX(){
  20.         return this.x;
  21.     }
  22.    
  23.     public String toString(){
  24.         return "Hallo ich bin ein Gegner mit folgenden Werten: \n" +
  25.         "Position: X: " + this.x + "Position: Y:" + this.y + "\nAnzahl Pfeile: "
  26.         + this.anzahl_Pfeile + " \nAußerdem habe ich einen Rucksack: " +
  27.         rucksack.toString();
  28.     }
  29.    
  30. }
  31.  
  32. public class Rucksack
  33. {
  34.     int anzahl_Manatraenke;
  35.     int anzahl_Heiltraenke;
  36.    
  37.     public Rucksack(int aM, int aH){
  38.         this.anzahl_Manatraenke = aM;
  39.         this.anzahl_Heiltraenke = aH;
  40.     }
  41.    
  42.     public String toString(){
  43.         return "Hallo, ich bin ein \n" +
  44.         "Rucksack mit folgendem Inhalt: \n" + " Anzahl Manatraenke: "
  45.         + this.anzahl_Manatraenke + " Anazahl Heiltraenke: "
  46.         + this.anzahl_Heiltraenke;
  47.     }
  48.    
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement