Skip to content
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
6 changes: 6 additions & 0 deletions TwoLiterStack/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Binary file added TwoLiterStack/bin/main/Main.class
Binary file not shown.
Binary file added TwoLiterStack/bin/main/TwoLiter.class
Binary file not shown.
2 changes: 2 additions & 0 deletions TwoLiterStack/src/main/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);

}
}
4 changes: 2 additions & 2 deletions TwoLiterStack/src/main/TwoLiter.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public static void add(Stack<TwoLiter> 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()));
}
}
Expand Down