Commit 8a31c1b5 authored by quinnhaigh's avatar quinnhaigh

final commit

parent c24ec7d6
......@@ -2,5 +2,6 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
<classpathentry kind="output" path="bin"/>
</classpath>
......@@ -330,7 +330,7 @@ public class FoodOrderingSystem1{
//method for payment
public static void checkOut() {
public static double checkOut() {
//display basket total cost.
......@@ -359,7 +359,7 @@ public class FoodOrderingSystem1{
System.out.println("Total = £" + total);
System.out.println("If you are not finished with your order go to choose items.");
home();
//get payment
System.out.println("Please enter the payment");
......@@ -376,19 +376,33 @@ public class FoodOrderingSystem1{
if(change > 0) {
System.out.println("Please take you change and your items and have a nice day.");
basketCode.clear();
basketName.clear();
basketQty.clear();
basketPrice.clear();
basketCost.clear();
System.exit(0);
}
else if(change == 0) {
System.out.println("Please take you items and have a nice day.");
basketCode.clear();
basketName.clear();
basketQty.clear();
basketPrice.clear();
basketCost.clear();
System.exit(0);
}
else
else if(change != 0) {
System.out.println("Your Balance is" + change);
}
System.out.println("Your Balance is" + change);
}
return change;
}
}
package foodOrderingSystem1;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
class checkoutTest {
FoodOrderingSystem1 FoodOrderingSystem1 = new FoodOrderingSystem1();
int total;
//test for ordering 2 pizza 1 sandwich and 3 coffees with successful payment of £40
@Test
void testOne() {
FoodOrderingSystem1.itemCode.add(1);
FoodOrderingSystem1.basketQty.get(2);
FoodOrderingSystem1.itemCode.add(3);
FoodOrderingSystem1.basketQty.get(1);
FoodOrderingSystem1.itemCode.add(7);
FoodOrderingSystem1.basketQty.get(3);
for(int i = 0; i < FoodOrderingSystem1.basketQty.size(); i++) {
total += FoodOrderingSystem1.basketPrice.get(i)* FoodOrderingSystem1.basketQty.get(i);
}
double result = FoodOrderingSystem1.checkOut();
assertEquals((total), result, "Error in transaction");
}
//test for ordering 2 burgers, 1 soft drink with an unsuccessful payment of £10
@Test
void testTwo() {
FoodOrderingSystem1.itemCode.add(2);
FoodOrderingSystem1.basketQty.get(2);
FoodOrderingSystem1.itemCode.add(5);
FoodOrderingSystem1.basketQty.get(1);
for(int i = 0; i < FoodOrderingSystem1.basketQty.size(); i++) {
total += FoodOrderingSystem1.basketPrice.get(i)* FoodOrderingSystem1.basketQty.get(i);
}
double result = FoodOrderingSystem1.checkOut();
assertEquals((total), result, "Error in transaction");
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment