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>
14 changes: 0 additions & 14 deletions TwoLiterStack/.settings/org.eclipse.jdt.core.prefs

This file was deleted.

9 changes: 7 additions & 2 deletions TwoLiterStack/src/main/Main.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
/*
* Bill Nicholson
* nicholdw@ucmail.uc.edu
* Charlie Hayes
* hayesc9@mail.uc.edu
* Assignment 10
* IT2045C Spring 2022
* Due: 4/3/2022
* This program creates a stack with two liter bottles of soda and prints the total price and amount of dr. pepper in the stack
*/
package main;

Expand Down Expand Up @@ -37,5 +41,6 @@ public static void main(String[] args) {
if (twoLiter.getFlavor().equals("Dr. Pepper")) {totalDrPepper++;}
}
System.out.println("Total Dr. Pepper = " + totalDrPepper);

}
}
12 changes: 8 additions & 4 deletions TwoLiterStack/src/main/TwoLiter.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
/*
* Bill Nicholson
* nicholdw@ucmail.uc.edu
* Charlie Hayes
* hayesc9@mail.uc.edu
* Assignment 10
* IT2045C Spring 2022
* Due: 4/3/2022
* This program creates a stack with two liter bottles of soda and prints the total price and amount of dr. pepper in the stack
*/
package main;

Expand Down Expand Up @@ -47,8 +51,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)], //removed the -1 so that the whole string array was being randomized
flavors[r.nextInt(flavors.length)],
1.00 + r.nextFloat()));
}
}
Expand Down