Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
RestaurantBookingSystem
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
sultan.khalifa
RestaurantBookingSystem
Commits
72f4fb8f
Commit
72f4fb8f
authored
Nov 16, 2020
by
Sully Khalifa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Formative.
parent
5960bc40
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
33 deletions
+43
-33
RestaurantBookingSystem.java
RestaurantBookingSystem/src/RestaurantBookingSystem.java
+43
-33
No files found.
RestaurantBookingSystem/src/RestaurantBookingSystem.java
View file @
72f4fb8f
...
@@ -67,7 +67,7 @@
...
@@ -67,7 +67,7 @@
}
}
//The main class in the program.
public
class
RestaurantBookingSystem
{
public
class
RestaurantBookingSystem
{
...
@@ -131,31 +131,27 @@
...
@@ -131,31 +131,27 @@
//main method
//main method
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
// Definition of stocks
//A list of menu items in an array style.
// ArrayList<Item> stocks = new ArrayList<Item>();
itemName
.
add
(
"Pizza "
);
// Basket
// ArrayList<Item> basket = new ArrayList<Item>();
itemName
.
add
(
"Pizza"
);
itemCode
.
add
(
1
);
itemCode
.
add
(
1
);
itemPrice
.
add
((
int
)
10
);
itemPrice
.
add
((
int
)
10
);
itemQty
.
add
(
50
);
itemQty
.
add
(
50
);
itemName
.
add
(
"Steak"
);
itemName
.
add
(
"Steak
"
);
itemCode
.
add
(
2
);
itemCode
.
add
(
2
);
itemPrice
.
add
((
int
)
7
);
itemPrice
.
add
((
int
)
7
);
itemQty
.
add
(
50
);
itemQty
.
add
(
50
);
itemName
.
add
(
"Sandwich"
);
itemName
.
add
(
"Sandwich
"
);
itemCode
.
add
(
3
);
itemCode
.
add
(
3
);
itemPrice
.
add
((
int
)
5
);
itemPrice
.
add
((
int
)
5
);
itemQty
.
add
(
50
);
itemQty
.
add
(
50
);
itemName
.
add
(
"Water"
);
itemName
.
add
(
"Water
"
);
itemCode
.
add
(
4
);
itemCode
.
add
(
4
);
itemPrice
.
add
((
int
)
1
);
itemPrice
.
add
((
int
)
1
);
itemQty
.
add
(
30
);
itemQty
.
add
(
30
);
...
@@ -166,22 +162,22 @@
...
@@ -166,22 +162,22 @@
itemPrice
.
add
((
int
)
2
);
itemPrice
.
add
((
int
)
2
);
itemQty
.
add
(
30
);
itemQty
.
add
(
30
);
itemName
.
add
(
"Tea "
);
itemName
.
add
(
"Tea
"
);
itemCode
.
add
(
6
);
itemCode
.
add
(
6
);
itemPrice
.
add
((
int
)
2
);
itemPrice
.
add
((
int
)
2
);
itemQty
.
add
(
20
);
itemQty
.
add
(
20
);
itemName
.
add
(
"Coffee"
);
itemName
.
add
(
"Coffee
"
);
itemCode
.
add
(
7
);
itemCode
.
add
(
7
);
itemPrice
.
add
((
int
)
2
);
itemPrice
.
add
((
int
)
2
);
itemQty
.
add
(
20
);
itemQty
.
add
(
20
);
itemName
.
add
(
"Ice cream"
);
itemName
.
add
(
"Ice cream
"
);
itemCode
.
add
(
8
);
itemCode
.
add
(
8
);
itemPrice
.
add
((
int
)
2
);
itemPrice
.
add
((
int
)
2
);
itemQty
.
add
(
20
);
itemQty
.
add
(
20
);
itemName
.
add
(
"Chocolate"
);
itemName
.
add
(
"Chocolate
"
);
itemCode
.
add
(
9
);
itemCode
.
add
(
9
);
itemPrice
.
add
((
int
)
1
);
itemPrice
.
add
((
int
)
1
);
itemQty
.
add
(
30
);
itemQty
.
add
(
30
);
...
@@ -192,7 +188,7 @@
...
@@ -192,7 +188,7 @@
System
.
out
.
println
();
System
.
out
.
println
();
//taking user input.
//taking user input.
System
.
out
.
println
(
"Please enter your full-name> "
);
System
.
out
.
println
(
"Please enter your full-name> "
);
userName
=
input
.
next
();
userName
=
input
.
next
Line
();
...
@@ -246,7 +242,7 @@
...
@@ -246,7 +242,7 @@
//-3- Select a product
//-3- Select a product
//Ask the user to enter item code
//Ask the user to enter item code
System
.
out
.
println
();
System
.
out
.
println
();
System
.
out
.
println
(
"Please enter an item code to select the item or 0
for payment
"
);
System
.
out
.
println
(
"Please enter an item code to select the item or 0
to make a payment>>
"
);
// Entering item code
// Entering item code
tempItemCode
=
input
.
nextInt
()
;
tempItemCode
=
input
.
nextInt
()
;
...
@@ -256,10 +252,13 @@
...
@@ -256,10 +252,13 @@
// termination point
// termination point
break
;
break
;
}
}
else
{
else
if
(
tempItemCode
>
9
)
{
System
.
out
.
println
(
"Invalid entry, Please try again."
);
}
else
{
// Ask for the quantity
// Ask for the quantity
System
.
out
.
println
(
"How many
do you need
? > "
);
System
.
out
.
println
(
"How many
would you like
? > "
);
tempItemQty
=
input
.
nextInt
();
tempItemQty
=
input
.
nextInt
();
...
@@ -267,25 +266,35 @@
...
@@ -267,25 +266,35 @@
if
(
itemQty
.
get
(
tempItemCode
)
>=
tempItemQty
)
{
if
(
itemQty
.
get
(
tempItemCode
)
>=
tempItemQty
)
{
// if available add it to the cart
// if available add it to the cart
addToBasket
(
tempItemCode
,
tempItemQty
);
addToBasket
(
tempItemCode
,
tempItemQty
);
}
}
if
(
tempItemCode
==
10
)
{
removeFromBasket
(
tempItemCode
,
tempItemQty
);
displayBox
();
}
// else show a message out of stock
// else show a message out of stock
else
{
else
{
System
.
out
.
println
(
"Out of stock"
);
System
.
out
.
println
(
"Out of stock
.
"
);
}
}
// Show cart with the total
// Show cart with the total
displayBox
();
displayBox
();
}
}
}
}
System
.
out
.
println
();
System
.
out
.
println
();
System
.
out
.
println
(
"A confirmation receipt for "
+
userName
+
" ,Table number "
// A message displaying the final confirmation, with customer name, table number, total cost.
+
x
+
y
+
"Total cost "
+
cost
);
System
.
out
.
println
(
"A confirmation receipt for: "
+
userName
+
" ,Table number: "
+
"["
+
x
+
y
+
"]"
+
" ,Total cost: £"
+
cost
+
"."
);
}
// Ending of main method
}
// Ending of main method
...
@@ -301,7 +310,7 @@
...
@@ -301,7 +310,7 @@
// Name Code Price
// Name Code Price
System
.
out
.
println
(
"Code \t: Name
\t: Price \t:
Qty\t: "
);
System
.
out
.
println
(
"Code \t: Name
\t: Price \t:
Qty\t: "
);
for
(
int
i
=
0
;
i
<
basketName
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
basketName
.
size
();
i
++
)
{
System
.
out
.
println
(
basketCode
.
get
(
i
)
+
" \t: "
+
basketName
.
get
(
i
)
+
"\t: "
System
.
out
.
println
(
basketCode
.
get
(
i
)
+
" \t: "
+
basketName
.
get
(
i
)
+
"\t: "
...
@@ -320,7 +329,7 @@
...
@@ -320,7 +329,7 @@
}
//------------- end of item removal method.
}
//------------- end of item removal method.
// Add
the specification of an item into a box
// Add
item properties into the shopping basket
private
static
void
addToBasket
(
int
tempItemCode
,
int
tempItemQty
)
{
private
static
void
addToBasket
(
int
tempItemCode
,
int
tempItemQty
)
{
basketCode
.
add
(
tempItemCode
);
basketCode
.
add
(
tempItemCode
);
...
@@ -328,7 +337,7 @@
...
@@ -328,7 +337,7 @@
basketQty
.
add
(
tempItemQty
);
basketQty
.
add
(
tempItemQty
);
basketPrice
.
add
(
tempItemQty
*
itemPrice
.
get
(
tempItemCode
));
basketPrice
.
add
(
tempItemQty
*
itemPrice
.
get
(
tempItemCode
));
}
}
// End of the adding to basked method.
...
@@ -344,7 +353,8 @@
...
@@ -344,7 +353,8 @@
}
}
// Display the total cost
// Display the total cost
System
.
out
.
println
(
"The total cost is "
+
cost
);
System
.
out
.
println
(
"The total cost is £"
+
cost
+
"."
);
System
.
out
.
println
();
// payment instructions
// payment instructions
...
@@ -369,7 +379,7 @@
...
@@ -369,7 +379,7 @@
//A method for displaying all tables
//A method for displaying all tables
public
static
void
displayTable1
()
{
public
static
void
displayTable1
()
{
// a for loop to iterate through all row and columns in order to display tables.
for
(
int
i
=
0
;
i
<
6
;
i
++)
{
for
(
int
i
=
0
;
i
<
6
;
i
++)
{
for
(
int
j
=
0
;
j
<
7
;
j
++)
{
for
(
int
j
=
0
;
j
<
7
;
j
++)
{
System
.
out
.
print
(
tables
[
i
][
j
]);
System
.
out
.
print
(
tables
[
i
][
j
]);
...
@@ -391,7 +401,7 @@
...
@@ -391,7 +401,7 @@
// Reads the positions
// Reads the positions
for table number.
x
=
input
.
nextInt
();
x
=
input
.
nextInt
();
y
=
input
.
nextInt
();
y
=
input
.
nextInt
();
tables
[
x
][
y
]
=
"[XX]"
;
tables
[
x
][
y
]
=
"[XX]"
;
...
@@ -429,13 +439,13 @@
...
@@ -429,13 +439,13 @@
private
static
void
itemList
()
{
private
static
void
itemList
()
{
// Name Code Price Quantity Description
// Name Code Price Quantity Description
System
.
out
.
println
(
"Code\t: Name \t: Price \t:Qty "
);
System
.
out
.
println
(
"Code\t: Name
\t: Price \t:Qty "
);
for
(
int
i
=
0
;
i
<
itemName
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
itemName
.
size
();
i
++
)
{
System
.
out
.
println
(
itemCode
.
get
(
i
)
+
" \t: "
+
itemName
.
get
(
i
)
+
" \t: "
+
itemPrice
.
get
(
i
)
+
"\t\t:"
+
itemQty
.
get
(
i
)
);
System
.
out
.
println
(
itemCode
.
get
(
i
)
+
" \t: "
+
itemName
.
get
(
i
)
+
" \t: "
+
itemPrice
.
get
(
i
)
+
"\t\t:"
+
itemQty
.
get
(
i
)
);
}
}
}
}
// Ending of the itemList method -----------------------------------
}
}
\ No newline at end of file
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