Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 19 additions & 16 deletions code/index.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Javascript Pizzeria</title>
<link rel="stylesheet" href="./style.css" />
<link
href="https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"
rel="stylesheet"
/>
</head>
<body>
<h1>Javascript Pizzeria</h1>
<p>Logic is executed automatically</p>
<script src="./script.js"></script>
</body>
</html>

<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Xing's Pizzeria</title>
<!-- https://xingspizzeria.netlify.app -->
<link rel="stylesheet" href="./style.css" />
<link
href="https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"
rel="stylesheet" />
</head>

<body>
<h1>Xing's Javascript Pizzeria</h1>
<p>Logic is executed automatically, refresh the page to restart the ordering process!</p>
<script src="./script.js"></script>
</body>

</html>
140 changes: 134 additions & 6 deletions code/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,146 @@

// Step 1 - Welcome and introduction
// Your code goes here
alert(
`Welcome to our Javascript Pizzeria. Ready to Start? - Click 'OK' to begin.`
alert (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be no space between JavaScript methods and their corresponding parentheses. Please go through your whole file and change where it applies.

"Welcome to my Javascript Pizzeria.Ready to Start ? - Click 'OK' to begin."
)

const userName = prompt ("What's your name?")
if (userName == "") {
alert ("Invalid entry, please try again. See you!")
exit (1)
}

alert (
`Nice to meet you ${userName.toUpperCase()}!`
)

// Step 2 - Food choice
// Your code goes here
const typeOfFood = parseInt (
prompt (`
What type of food would you like to order?
Enter a number:
1 - Pizza
2 - Pasta
3 - Salad
`)
)

let selectedFood = ""

if (typeOfFood === 1) {
selectedFood = "Pizza"
} else if (typeOfFood === 2) {
selectedFood = "Pasta"
} else if (typeOfFood === 3) {
selectedFood = "Salad"
} else {
alert ("Invalid choice. Please start over again and select a valid number between 1 to 3.")
exit (1)
}

alert (
`You've chosen ${selectedFood}!`
)

// Step 3 - Subtype choice
// Your code goes here
let subFoodNr = ""
let subFood = []

switch (selectedFood) {
case "Pizza":
subFoodNr = parseInt (
prompt (`
Select a Pizza type, enter a number:
1 - Napolitana
2 - Hawaian
3 - Pepperoni
`)
)
subFood = ["Napolitana","Hawaian","Pepperoni"]
break

case "Pasta":
subFoodNr = parseInt (
prompt (`
Select a Pasta type, enter a number:
1 - Spaghetti Carbonara
2 - Fettuccine Alfredo
3 - Cheesy Tortellini
`)
)
subFood = ["Spaghetti Carbonara","Fettuccine Alfredo","Cheesy Tortellini"]
break

case "Salad":
subFoodNr = parseInt (
prompt (`
Select a Salad type, enter a number:
1 - Caesar Salad
2 - Caprese Salad
3 - Greek Salad
`)
)
subFood = ["Caesar Salad","Caprese Salad","Greek Salad"]
break

default:
alert("Invalid entry, please try again. See you!")
}

if (subFoodNr === 1 || subFoodNr === 2 || subFoodNr === 3) {
alert (`
You've chosen ${subFood[subFoodNr-1]}!
`)
} else {
alert("Invalid entry, please try again. See you!")
exit(1)
}
// Dry js code by using ||

// Step 4 - Age
// Your code goes here
let age = prompt ("Is this food for a child or an adult? Type your age:")
let ageGroup = ""
let cost = ""

if (age <= 17) {
ageGroup = "Child"
cost = "€10"
} else if (age > 17) {
ageGroup = "Adult"
cost = "€15"
} else {
alert ("Invalid entry, please try again. See you!")
exit (1)
}

//display the order message and the associated cost
if (ageGroup && cost) {
alert(`
You've chosen a ${subFood[subFoodNr-1]} for a ${ageGroup}. The cost will be ${cost}.
`)
}

// Step 5 - Order confirmation
// Your code goes here
let detail = `You are about to order a ${selectedFood} (${subFood[subFoodNr-1]}) for a ${ageGroup}. The cost will be ${cost}. Would you like to confirm your order?`

let confirmNr = parseInt(
prompt(`
${detail}
Enter a number to comfirm:
1 - Yes
2 - No
`)
)

if (confirmNr === 1) {
alert(`
Thank you for your order! Your delicious meal will be prepared. See you soon!👍
`)
} else if (confirmNr === 2) {
alert(`
No problem. Come back and order anytime you want!🖖
`)
} else {
alert ("Invalid entry, please select 1 for Yes or 2 for No.")
}
19 changes: 18 additions & 1 deletion code/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,25 @@ body {
align-items: center;
flex-direction: column;
min-height: 100vh;
margin: 0 50px;
}

h1,p {
text-align: center;
}

h1::before{
content: url("https://img.icons8.com/?size=100&id=37466&format=png&color=000000");
width: 20px;
padding-right: 10px;
}

h1{
font-size: 3rem;
font-weight: 600;
}

p {
font-size: 1.5em;
font-size: 1.5rem;
margin-top: 3rem;
}
2 changes: 1 addition & 1 deletion pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Netlify link
Add your Netlify link here like this (update with the correct one):

https://my-netlify-link.netlify.app
https://xingspizzeria.netlify.app

PS. Don't forget to add it in your readme as well.