Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Done product manager #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
23 changes: 17 additions & 6 deletions src/main/java/com/github/curriculeon/GenericInventory.java
Original file line number Diff line number Diff line change
@@ -1,31 +1,42 @@
package com.github.curriculeon;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
* Created by leon on 12/16/2019.
*/
public class GenericInventory<SomeType> implements InventoryInterface<SomeType> {
public class GenericInventory<SomeType> implements InventoryInterface<SomeType>, Iterable<SomeType> {
List<SomeType> productManager = new ArrayList<>();

@Override
public void add(SomeType someObject) {

this.productManager.add(someObject);
}

@Override
public Boolean contains(SomeType someObject) {
return null;
return this.productManager.contains(someObject);
}

@Override
public SomeType get(int indexOfElement) {
return null;
return this.productManager.get(indexOfElement);
}

@Override
public SomeType remove(int indexOfElement) {
return null;
return this.productManager.remove(indexOfElement);
}

@Override
public SomeType[] toArray(SomeType[] objectsToBeAdded) {
return null;
return this.productManager.toArray(objectsToBeAdded);
}

@Override
public Iterator<SomeType> iterator() {
return this.productManager.iterator();
}
}
21 changes: 15 additions & 6 deletions src/main/java/com/github/curriculeon/ItemInventory.java
Original file line number Diff line number Diff line change
@@ -1,31 +1,40 @@
package com.github.curriculeon;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
* Created by leon on 12/16/2019.
*/
public class ItemInventory implements InventoryInterface<Item> {
public class ItemInventory implements InventoryInterface<Item>, Iterable<Item> {
List<Item> productManager = new ArrayList<>();
@Override
public void add(Item someObject) {

this.productManager.add(someObject);
}

@Override
public Boolean contains(Item someObject) {
return null;
return this.productManager.contains(someObject);
}

@Override
public Item get(int indexOfElement) {
return null;
return this.productManager.get(indexOfElement);
}

@Override
public Item remove(int indexOfElement) {
return null;
return this.productManager.remove(indexOfElement);
}

@Override
public Item[] toArray(Item[] objectsToBeAdded) {
return new Item[0];
return this.productManager.toArray(objectsToBeAdded);
}

@Override
public Iterator<Item> iterator() {
return this.productManager.iterator();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
public class RemoveTest {
// given
private <SomeType> void test(SomeType[] expectedItems, SomeType[] objectsToBeAdded, int indexOfElement) {
SomeType[] actualItems = objectsToBeAdded.clone();
SomeType[] actualItems = expectedItems.clone();
GenericInventory<SomeType> genericInventory = new GenericInventory<>();
for (SomeType someObject : objectsToBeAdded) {
genericInventory.add(someObject);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
public class RemoveTest {
// given
private void test(Item[] expectedItems, Item[] objectsToBeAdded, int indexOfElement) {
Item[] actualItems = objectsToBeAdded.clone();
Item[] actualItems = expectedItems.clone();
GenericInventory<Item> genericInventory = new GenericInventory<>();
for (Item someObject : objectsToBeAdded) {
genericInventory.add(someObject);
Expand Down