From cb64cc4e07e889f8986c1fefa230d124d92812c3 Mon Sep 17 00:00:00 2001 From: SteffenLm <33038091+SteffenLm@users.noreply.github.com> Date: Wed, 26 Oct 2022 11:58:21 +0200 Subject: [PATCH 1/3] implement solution --- Creature.java | 31 +++++++++++++++++++++++++++++++ Exercise.java | 9 ++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 Creature.java diff --git a/Creature.java b/Creature.java new file mode 100644 index 0000000..3d1db21 --- /dev/null +++ b/Creature.java @@ -0,0 +1,31 @@ +public class Creature { + + private String name; + private int attackValue; + private int hitpoints; + + public Creature(String name, int attackValue, int hitpoints) { + this.name = name; + this.attackValue = attackValue; + this.hitpoints = hitpoints; + } + + public String getName() { + return name; + } + + public int getAttackValue() { + return attackValue; + } + + public int getHitpoints() { + return hitpoints; + } + + public void attackCreature(Creature creature) { + creature.hitpoints -= this.attackValue; + System.out.println(this.name + " greift " + creature.name + " an und erzielt " + this.attackValue + " Schaden"); + System.out.println(creature.name + " hat noch " + creature.hitpoints + " Lebenspunkte"); + } + +} diff --git a/Exercise.java b/Exercise.java index 3c092f9..b5b5c69 100644 --- a/Exercise.java +++ b/Exercise.java @@ -1,6 +1,13 @@ public class Exercise { public static void main(String[] args) { - // implement exercise here + Creature zombie = new Creature("Zombie", 2, 10); + Creature vampire = new Creature("Vampir", 4, 6); + + zombie.attackCreature(vampire); + vampire.attackCreature(zombie); + zombie.attackCreature(vampire); + vampire.attackCreature(zombie); + } } From 9c01d77a4616edee14df3c569363822f509dca6c Mon Sep 17 00:00:00 2001 From: github-actions <> Date: Wed, 26 Oct 2022 09:58:38 +0000 Subject: [PATCH 2/3] Google Java Format --- Creature.java | 9 +++++++-- Exercise.java | 1 - 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Creature.java b/Creature.java index 3d1db21..9c93fb2 100644 --- a/Creature.java +++ b/Creature.java @@ -24,8 +24,13 @@ public int getHitpoints() { public void attackCreature(Creature creature) { creature.hitpoints -= this.attackValue; - System.out.println(this.name + " greift " + creature.name + " an und erzielt " + this.attackValue + " Schaden"); + System.out.println( + this.name + + " greift " + + creature.name + + " an und erzielt " + + this.attackValue + + " Schaden"); System.out.println(creature.name + " hat noch " + creature.hitpoints + " Lebenspunkte"); } - } diff --git a/Exercise.java b/Exercise.java index b5b5c69..6863923 100644 --- a/Exercise.java +++ b/Exercise.java @@ -8,6 +8,5 @@ public static void main(String[] args) { vampire.attackCreature(zombie); zombie.attackCreature(vampire); vampire.attackCreature(zombie); - } } From 73f08c3f60eefe106f0f0fb099dd21ecedcc61e2 Mon Sep 17 00:00:00 2001 From: SteffenLm <33038091+SteffenLm@users.noreply.github.com> Date: Fri, 19 Dec 2025 20:58:18 +0000 Subject: [PATCH 3/3] add dev container --- .devcontainer.json | 3 +++ .vscode/extensions.json | 5 +++++ 2 files changed, 8 insertions(+) create mode 100644 .devcontainer.json create mode 100644 .vscode/extensions.json diff --git a/.devcontainer.json b/.devcontainer.json new file mode 100644 index 0000000..bfbeb0d --- /dev/null +++ b/.devcontainer.json @@ -0,0 +1,3 @@ +{ + "image": "mcr.microsoft.com/devcontainers/java:21" +} \ No newline at end of file diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..add4f4e --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "vscjava.vscode-java-pack" + ] +} \ No newline at end of file