Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
food ordering system
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
quinn.haigh
food ordering system
Commits
8a31c1b5
Commit
8a31c1b5
authored
Dec 03, 2019
by
quinnhaigh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
final commit
parent
c24ec7d6
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
69 additions
and
7 deletions
+69
-7
.classpath
.classpath
+1
-0
FoodOrderingSystem1.java
src/foodOrderingSystem1/FoodOrderingSystem1.java
+21
-7
checkoutTest.java
src/foodOrderingSystem1/checkoutTest.java
+47
-0
No files found.
.classpath
View file @
8a31c1b5
...
...
@@ -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>
src/foodOrderingSystem1/FoodOrderingSystem1.java
View file @
8a31c1b5
...
...
@@ -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
);
}
return
change
;
}
}
src/foodOrderingSystem1/checkoutTest.java
0 → 100644
View file @
8a31c1b5
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"
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment