diff --git a/TwoLiterStack/.classpath b/TwoLiterStack/.classpath
new file mode 100644
index 0000000..14cbaf9
--- /dev/null
+++ b/TwoLiterStack/.classpath
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/TwoLiterStack/bin/.classpath b/TwoLiterStack/bin/.classpath
new file mode 100644
index 0000000..14cbaf9
--- /dev/null
+++ b/TwoLiterStack/bin/.classpath
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/TwoLiterStack/bin/.gitignore b/TwoLiterStack/bin/.gitignore
index ddf9c65..4f00cd9 100644
--- a/TwoLiterStack/bin/.gitignore
+++ b/TwoLiterStack/bin/.gitignore
@@ -1 +1 @@
-/main/
+/src/
diff --git a/TwoLiterStack/bin/.project b/TwoLiterStack/bin/.project
new file mode 100644
index 0000000..96bd9cd
--- /dev/null
+++ b/TwoLiterStack/bin/.project
@@ -0,0 +1,17 @@
+
+
+ TwoLiterStack
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/TwoLiterStack/bin/.settings/org.eclipse.jdt.core.prefs b/TwoLiterStack/bin/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..2b084d8
--- /dev/null
+++ b/TwoLiterStack/bin/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,14 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=12
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=12
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
+org.eclipse.jdt.core.compiler.release=enabled
+org.eclipse.jdt.core.compiler.source=12
diff --git a/TwoLiterStack/src/main/Main.java b/TwoLiterStack/src/main/Main.java
index b5e47e3..dbb474d 100644
--- a/TwoLiterStack/src/main/Main.java
+++ b/TwoLiterStack/src/main/Main.java
@@ -1,8 +1,12 @@
/*
- * Bill Nicholson
- * nicholdw@ucmail.uc.edu
+ * Professor Bill Nicholsons code, Edited by Joshua Ciulla..
+ * ciullaja@mail.uc.edu
+ * Assignment #: 10
+ * IT 2045C Spring Semester
+ * This is Professor Bill Nicholsons code, I am just editing the code. I will be fixing the Dr. Pepper problem
*/
-package main;
+
+package src.main;
import java.text.DecimalFormat;
import java.util.Stack;
@@ -10,6 +14,10 @@
public class Main {
public static void main(String[] args) {
+
+
+ Stack myStack = new Stack(); // Adding a paramater to this class and Joshua added this
+
// ToDo Declare and instantiate a TwoLiterStack object
Stack twoLiterStack = new Stack();
@@ -25,7 +33,7 @@ public static void main(String[] args) {
totalPrice += twoLiter.getPrice();
}
-
+ //
// ToDo Print the total price to exactly two decimal places.
// ToDo in the comments here, explain why this number changes each time you run the program.
DecimalFormat df2 = new DecimalFormat("#.##");
@@ -33,9 +41,13 @@ public static void main(String[] args) {
// ToDo Compute the number of Dr. Pepper 2-liters in the stack
int totalDrPepper = 0;
+ myStack.add("Dr. Pepper"); // Joshua Added this
+ String myPop = myStack.pop(); // Joshua added this
+
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..b6b8dbb 100644
--- a/TwoLiterStack/src/main/TwoLiter.java
+++ b/TwoLiterStack/src/main/TwoLiter.java
@@ -1,20 +1,25 @@
/*
- * Bill Nicholson
- * nicholdw@ucmail.uc.edu
+ * Professor Bill Nicholsons code, Edited by Joshua Ciulla.
+ * ciullaja@mail.uc.edu
+ * Assignment #: 10
+ * IT 2045C Spring Semester
+ * This is Professor Bill Nicholsons code, I am just editing the code. I will be fixing the Dr. Pepper problem.
*/
-package main;
+
+package src.main;
import java.util.Random;
import java.util.Stack;
-
+//
/**
* Model a 2-liter of soda in a grocery store
* @author nicomp
*
*/
public class TwoLiter {
- private static String[] flavors = {"Coke Classic", "Diet Coke", "Coke Zero", "New Coke", "Cherry Coke", "Caffeine Free Coke", "Dr. Pepper"};
- private static String[] UPCs = {"049000050103", "00049000050110", "00049000050141", "xxxxxxxxxxxxxx", " 00049000050165", "00049000006131", "00078000082463"};
+ private static String[] flavors = {"Coke Classic", "Diet Coke", "Coke Zero", "Dr. Pepper", "Cherry Coke", "Caffeine Free Coke", "New Coke"};
+ private static String[] UPCs = {"049000050103", "00049000050110", "00049000050141", "00078000082463", " 00049000050165", "00049000006131", "0"};
+ // I switched the New Coke that did not have any value to the the back because Dr. Pepper was cut out. So I changed the position of new coke with Dr.Pepper for it to work.
private String UPC;
private String flavor;
private double price;
@@ -44,12 +49,13 @@ public TwoLiter(TwoLiter twoLiter) {
* @param count The number of TwoLiter objects to add
*/
public static void add(Stack twoLiterStack, int count ) {
-// Random r = new Random(42);
- Random r = new Random();
+ Random r = new Random(42);
+ Random r1 = 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)],
- 1.00 + r.nextFloat()));
+ twoLiterStack.add(new TwoLiter(UPCs[r1.nextInt(UPCs.length - 1)],
+ flavors[r1.nextInt(flavors.length - 1)],
+ 1.00 + r1.nextFloat()));
+
}
}
/**
@@ -102,3 +108,5 @@ public String toString() {
return UPC + ", " + flavor + ", " + price;
}
}
+
+// I edited the code and I switched "New Coke" with no value to Dr.Pepper that has value and now I get output for Dr.Pepper to be added to the stack. I also added a parameter to the class as well to ensure that Dr.Pepper is added to the stack.