diff --git a/code/index.html b/code/index.html index f7844d6b..7a15255e 100644 --- a/code/index.html +++ b/code/index.html @@ -1,18 +1,21 @@ - - - - Javascript Pizzeria - - - - -

Javascript Pizzeria

-

Logic is executed automatically

- - - + + + + + Xing's Pizzeria + + + + + + +

Xing's Javascript Pizzeria

+

Logic is executed automatically, refresh the page to restart the ordering process!

+ + + + \ No newline at end of file diff --git a/code/script.js b/code/script.js index 34ca0f34..d07ac8e6 100644 --- a/code/script.js +++ b/code/script.js @@ -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 ( + "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.") +} \ No newline at end of file diff --git a/code/style.css b/code/style.css index d384d122..516712b2 100644 --- a/code/style.css +++ b/code/style.css @@ -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; } diff --git a/pull_request_template.md b/pull_request_template.md index e239e19f..c6cffebd 100644 --- a/pull_request_template.md +++ b/pull_request_template.md @@ -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.