Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"image": "mcr.microsoft.com/devcontainers/java:21"
}
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"vscjava.vscode-java-pack"
]
}
18 changes: 9 additions & 9 deletions Crate.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
public class Crate {
public class Crate<T> {

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();
}
Expand All @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion Exercise.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
public class Exercise {

public static void main(String[] args) {
Crate crate = new Crate();
Crate<Bottle> crate = new Crate<Bottle>();

try {
crate.insertBottle(new BeerBottle(), 1);
Expand Down
Loading