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
Show 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 @@
}
//The main class in the program.
public
class
RestaurantBookingSystem
{
...
...
@@ -131,31 +131,27 @@
//main method
public
static
void
main
(
String
[]
args
)
{
// Definition of stocks
// ArrayList<Item> stocks = new ArrayList<Item>();
// Basket
// ArrayList<Item> basket = new ArrayList<Item>();
itemName
.
add
(
"Pizza"
);
//A list of menu items in an array style.
itemName
.
add
(
"Pizza "
);
itemCode
.
add
(
1
);
itemPrice
.
add
((
int
)
10
);
itemQty
.
add
(
50
);
itemName
.
add
(
"Steak"
);
itemName
.
add
(
"Steak
"
);
itemCode
.
add
(
2
);
itemPrice
.
add
((
int
)
7
);
itemQty
.
add
(
50
);
itemName
.
add
(
"Sandwich"
);
itemName
.
add
(
"Sandwich
"
);
itemCode
.
add
(
3
);
itemPrice
.
add
((
int
)
5
);
itemQty
.
add
(
50
);
itemName
.
add
(
"Water"
);
itemName
.
add
(
"Water
"
);
itemCode
.
add
(
4
);
itemPrice
.
add
((
int
)
1
);
itemQty
.
add
(
30
);
...
...
@@ -171,17 +167,17 @@
itemPrice
.
add
((
int
)
2
);
itemQty
.
add
(
20
);
itemName
.
add
(
"Coffee"
);
itemName
.
add
(
"Coffee
"
);
itemCode
.
add
(
7
);
itemPrice
.
add
((
int
)
2
);
itemQty
.
add
(
20
);
itemName
.
add
(
"Ice cream"
);
itemName
.
add
(
"Ice cream
"
);
itemCode
.
add
(
8
);
itemPrice
.
add
((
int
)
2
);
itemQty
.
add
(
20
);
itemName
.
add
(
"Chocolate"
);
itemName
.
add
(
"Chocolate
"
);
itemCode
.
add
(
9
);
itemPrice
.
add
((
int
)
1
);
itemQty
.
add
(
30
);
...
...
@@ -192,7 +188,7 @@
System
.
out
.
println
();
//taking user input.
System
.
out
.
println
(
"Please enter your full-name> "
);
userName
=
input
.
next
();
userName
=
input
.
next
Line
();
...
...
@@ -246,7 +242,7 @@
//-3- Select a product
//Ask the user to enter item code
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
tempItemCode
=
input
.
nextInt
()
;
...
...
@@ -256,10 +252,13 @@
// termination point
break
;
}
else
{
else
if
(
tempItemCode
>
9
)
{
System
.
out
.
println
(
"Invalid entry, Please try again."
);
}
else
{
// Ask for the quantity
System
.
out
.
println
(
"How many
do you need
? > "
);
System
.
out
.
println
(
"How many
would you like
? > "
);
tempItemQty
=
input
.
nextInt
();
...
...
@@ -268,24 +267,34 @@
// if available add it to the cart
addToBasket
(
tempItemCode
,
tempItemQty
);
}
if
(
tempItemCode
==
10
)
{
removeFromBasket
(
tempItemCode
,
tempItemQty
);
displayBox
();
}
// else show a message out of stock
else
{
System
.
out
.
println
(
"Out of stock"
);
System
.
out
.
println
(
"Out of stock
.
"
);
}
// Show cart with the total
displayBox
();
}
}
System
.
out
.
println
();
System
.
out
.
println
(
"A confirmation receipt for "
+
userName
+
" ,Table number "
+
x
+
y
+
"Total cost "
+
cost
);
// A message displaying the final confirmation, with customer name, table number, total cost.
System
.
out
.
println
(
"A confirmation receipt for: "
+
userName
+
" ,Table number: "
+
"["
+
x
+
y
+
"]"
+
" ,Total cost: £"
+
cost
+
"."
);
}
// Ending of main method
...
...
@@ -301,7 +310,7 @@
// 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
++
)
{
System
.
out
.
println
(
basketCode
.
get
(
i
)
+
" \t: "
+
basketName
.
get
(
i
)
+
"\t: "
...
...
@@ -320,7 +329,7 @@
}
//------------- 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
)
{
basketCode
.
add
(
tempItemCode
);
...
...
@@ -328,7 +337,7 @@
basketQty
.
add
(
tempItemQty
);
basketPrice
.
add
(
tempItemQty
*
itemPrice
.
get
(
tempItemCode
));
}
}
// End of the adding to basked method.
...
...
@@ -344,7 +353,8 @@
}
// 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
...
...
@@ -369,7 +379,7 @@
//A method for displaying all tables
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
j
=
0
;
j
<
7
;
j
++)
{
System
.
out
.
print
(
tables
[
i
][
j
]);
...
...
@@ -391,7 +401,7 @@
// Reads the positions
// Reads the positions
for table number.
x
=
input
.
nextInt
();
y
=
input
.
nextInt
();
tables
[
x
][
y
]
=
"[XX]"
;
...
...
@@ -435,7 +445,7 @@
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