Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Gegner
- {
- private int x;
- private int y;
- private int anzahl_Pfeile;
- private Rucksack rucksack;
- public Gegner(int x, int y){
- this.x = x;
- this.y = y;
- anzahl_Pfeile = 10;
- rucksack = new Rucksack(2,2);
- }
- public void setX(int x){
- this.x = x;
- }
- public int getX(){
- return this.x;
- }
- public String toString(){
- return "Hallo ich bin ein Gegner mit folgenden Werten: \n" +
- "Position: X: " + this.x + "Position: Y:" + this.y + "\nAnzahl Pfeile: "
- + this.anzahl_Pfeile + " \nAußerdem habe ich einen Rucksack: " +
- rucksack.toString();
- }
- }
- public class Rucksack
- {
- int anzahl_Manatraenke;
- int anzahl_Heiltraenke;
- public Rucksack(int aM, int aH){
- this.anzahl_Manatraenke = aM;
- this.anzahl_Heiltraenke = aH;
- }
- public String toString(){
- return "Hallo, ich bin ein \n" +
- "Rucksack mit folgendem Inhalt: \n" + " Anzahl Manatraenke: "
- + this.anzahl_Manatraenke + " Anazahl Heiltraenke: "
- + this.anzahl_Heiltraenke;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement