diff --git a/TwoLiterStack/.classpath b/TwoLiterStack/.classpath new file mode 100644 index 0000000..fb50116 --- /dev/null +++ b/TwoLiterStack/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/TwoLiterStack/bin/main/Main.class b/TwoLiterStack/bin/main/Main.class new file mode 100644 index 0000000..6b70155 Binary files /dev/null and b/TwoLiterStack/bin/main/Main.class differ diff --git a/TwoLiterStack/bin/main/TwoLiter.class b/TwoLiterStack/bin/main/TwoLiter.class new file mode 100644 index 0000000..29a9bce Binary files /dev/null and b/TwoLiterStack/bin/main/TwoLiter.class differ diff --git a/TwoLiterStack/src/main/Main.java b/TwoLiterStack/src/main/Main.java index b5e47e3..4bc1571 100644 --- a/TwoLiterStack/src/main/Main.java +++ b/TwoLiterStack/src/main/Main.java @@ -33,9 +33,11 @@ public static void main(String[] args) { // ToDo Compute the number of Dr. Pepper 2-liters in the stack int totalDrPepper = 0; + for (TwoLiter twoLiter : twoLiterStack) { if (twoLiter.getFlavor().equals("Dr. Pepper")) {totalDrPepper++;} } System.out.println("Total Dr. Pepper = " + totalDrPepper); + } } diff --git a/TwoLiterStack/src/main/TwoLiter.java b/TwoLiterStack/src/main/TwoLiter.java index 9a6d0d0..c706a9d 100644 --- a/TwoLiterStack/src/main/TwoLiter.java +++ b/TwoLiterStack/src/main/TwoLiter.java @@ -47,8 +47,8 @@ public static void add(Stack twoLiterStack, int count ) { // Random r = new Random(42); Random r = new Random(); for (int i = 0; i < count; i++) { - twoLiterStack.add(new TwoLiter(UPCs[r.nextInt(UPCs.length - 1)], - flavors[r.nextInt(flavors.length - 1)], + twoLiterStack.add(new TwoLiter(UPCs[r.nextInt(UPCs.length)], + flavors[r.nextInt(flavors.length)], 1.00 + r.nextFloat())); } }