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 diff --git a/Crate.java b/Crate.java index 1e380b0..7c87ae1 100644 --- a/Crate.java +++ b/Crate.java @@ -1,13 +1,13 @@ -public class Crate { +public class Crate { - private Bottle box1; - private Bottle box2; - private Bottle box3; - private Bottle box4; - private Bottle box5; - private Bottle box6; + private T box1; + private T box2; + private T box3; + private T box4; + private T box5; + private T box6; - public void insertBottle(Bottle bottle, int box) throws CrateIndexOutOfBoundsException { + public void insertBottle(T bottle, int box) throws CrateIndexOutOfBoundsException { if (box < 1 || box > 6) { throw new CrateIndexOutOfBoundsException(); } @@ -22,7 +22,7 @@ public void insertBottle(Bottle bottle, int box) throws CrateIndexOutOfBoundsExc } } - public Bottle takeBottle(int box) throws CrateIndexOutOfBoundsException { + public T takeBottle(int box) throws CrateIndexOutOfBoundsException { if (box < 1 || box > 6) { throw new CrateIndexOutOfBoundsException(); } diff --git a/Exercise.java b/Exercise.java index 36de0b3..e4b94c5 100644 --- a/Exercise.java +++ b/Exercise.java @@ -1,7 +1,7 @@ public class Exercise { public static void main(String[] args) { - Crate crate = new Crate(); + Crate crate = new Crate(); try { crate.insertBottle(new BeerBottle(), 1);