Fixed item removal.

This commit is contained in:
2025-10-09 11:34:47 +02:00
parent 10171a3110
commit 30991a2ccd
2 changed files with 4 additions and 5 deletions
+2 -2
View File
@@ -111,9 +111,9 @@ public class Fridge { // TODO: change
FridgeItem[] newItems = new FridgeItem[items.length - 1];
for (int j = 0; j < newItems.length; j++) {
if (j < i) {
newItems[j] = items[i];
newItems[j] = items[j];
} else {
newItems[j] = items[i + 1];
newItems[j] = items[j + 1];
}
}
// and replace the old items with the new ones
+2 -3
View File
@@ -62,7 +62,6 @@ public class MediaLibrary { // TODO: change
if (items.length == maxItems) { // Cannot add more items to the media library
return false;
}
// all checks ok, add the item
MediaItem[] newItems = new MediaItem[items.length + 1];
for (int j = 0; j < items.length; j++) {
@@ -108,9 +107,9 @@ public class MediaLibrary { // TODO: change
MediaItem[] newItems = new MediaItem[items.length - 1];
for (int j = 0; j < newItems.length; j++) {
if (j < i) {
newItems[j] = items[i];
newItems[j] = items[j];
} else {
newItems[j] = items[i + 1];
newItems[j] = items[j + 1];
}
}
// and replace the old items with the new ones