-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathInventory.java
More file actions
41 lines (33 loc) · 1.1 KB
/
Inventory.java
File metadata and controls
41 lines (33 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package gross.ryan;
import org.junit.Test;
import java.util.ArrayList;
/**
* Created by ryangross on 1/18/17.
*/
public class Inventory {
private ArrayList<Product> anInventory = new ArrayList<Product>();
public ArrayList<Product> getInventory() {
return anInventory;
}
public void addProduct(Product newProduct) {
this.getInventory().add(newProduct);
}
public double totalInventoryValue() {
double total = 0.0;
for(int i = 0; i < this.getInventory().size(); i++) {
total += this.getInventory().get(i).totalValue();
}
return total;
}
// Checks quantity on hand. If zero, still shows it so you can replenish.
public String checkItem(int anID) {
String answer = "Item not found";
for(int i = 0; i < this.getInventory().size(); i++) {
if (this.getInventory().get(i).getID() == anID) {
answer = "Item #" + this.getInventory().get(i).getID() + ": " + this.getInventory().get(i).getQOH() +
" units on hand.";
}
}
return answer;
}
}