From 0eff012193dfe307b808c278136cb1c230fba88f Mon Sep 17 00:00:00 2001 From: HeleneWestrin Date: Mon, 2 Sep 2024 14:58:52 +0200 Subject: [PATCH 01/13] Added prompt for name and food type selection --- README.md | 4 ++-- code/index.html | 2 +- code/script.js | 53 ++++++++++++++++++++++++++++++++++++------------- code/style.css | 12 +++++++++-- instructions.md | 1 - 5 files changed, 52 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 33c7e601..8c3533dc 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# Project Name +# Bella Italia Pizzeria -Replace this readme with your own information about your project. Start by briefly describing the assignment in a sentence or two. Keep it short and to the point. +The task is to create a order functionality for a fictional pizzeria using JavaScript concepts like variables, conditionals and native methods. ## The problem diff --git a/code/index.html b/code/index.html index f7844d6b..61ba035b 100644 --- a/code/index.html +++ b/code/index.html @@ -3,7 +3,7 @@ - Javascript Pizzeria + Bella Italia Pizzeria Date: Mon, 2 Sep 2024 22:34:38 +0200 Subject: [PATCH 02/13] Added logic for selection of sub type --- code/index.html | 4 +-- code/script.js | 87 +++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 82 insertions(+), 9 deletions(-) diff --git a/code/index.html b/code/index.html index 61ba035b..1e2d5c87 100644 --- a/code/index.html +++ b/code/index.html @@ -11,8 +11,8 @@ /> -

Javascript Pizzeria

-

Logic is executed automatically

+

Bella Itala Pizzeria

+

Place your order here.

diff --git a/code/script.js b/code/script.js index bc2ed170..6b0e371e 100644 --- a/code/script.js +++ b/code/script.js @@ -11,12 +11,13 @@ document.addEventListener("DOMContentLoaded", function () { do { foodType = parseInt( prompt( - `Welcome ${userName}! What would you like to eat today? + `Ciao ${userName} 👋 + What would you like to eat today? Enter a number: - 1 – Pizza - 2 – Pasta - 3 – Salad + 1 – Pizza 🍕 + 2 – Pasta 🍝 + 3 – Salad 🥗 ` ) ); @@ -29,12 +30,84 @@ document.addEventListener("DOMContentLoaded", function () { foodType = "Salad"; } else { foodType = null; - alert("Wrong input. Please type 1, 2 or 3 to make your selection."); + alert( + "Sorry, that's not on the menu today. Please type 1, 2 or 3 to make your selection." + ); } } while (foodType === null); - // Step 4 - Subtype choice - // Your code goes here + // Step 3 - Subtype choice + let subFoodType; + let subFoodSelection; + + if (foodType === "Pizza") { + subFoodType = `Enter a number: + 1 – Margaritha + 2 – Capricciosa + 3 – Hawaiis`; + } else if (foodType === "Pasta") { + subFoodType = `Enter a number: + 1 – Carbonara + 2 – Spaghetti Alle Vongole + 3 – Lasagne`; + } else if (foodType === "Salad") { + subFoodType = `Enter a number: + 1 – Caprese + 2 – Insalata Russa + 3 – Giardiniera`; + } else { + subFoodType = null; + } + + do { + subFoodSelection = parseInt( + prompt( + `${foodType}, what an excellent choice! + What type would you like? + + ${subFoodType} + ` + ) + ); + + if (foodType === "Pizza") { + if (subFoodSelection === 1) { + subFoodSelection = "Margaritha"; + } else if (subFoodSelection === 2) { + subFoodSelection = "Capricciosa"; + } else if (subFoodSelection === 3) { + subFoodSelection = "Hawaii"; + } else { + subFoodSelection = null; + } + } else if (foodType === "Pasta") { + if (subFoodSelection === 1) { + subFoodSelection = "Carbonara"; + } else if (subFoodSelection === 2) { + subFoodSelection = "Spaghetti Alle Vongole"; + } else if (subFoodSelection === 3) { + subFoodSelection = "Lasagne"; + } else { + subFoodSelection = null; + } + } else if (foodType === "Salad") { + if (subFoodSelection === 1) { + subFoodSelection = "Caprese"; + } else if (subFoodSelection === 2) { + subFoodSelection = "Insalata Russa"; + } else if (subFoodSelection === 3) { + subFoodSelection = "Giardiniera"; + } else { + subFoodSelection = null; + } + } + + if (subFoodSelection === null) { + alert( + "We're all out of that for today I'm afraid. Please type 1, 2 or 3 to make your selection." + ); + } + } while (subFoodSelection === null); // Step 5 - Age // Your code goes here From 2ea3ab57d61defaff7ae6c7299c4301704575cb5 Mon Sep 17 00:00:00 2001 From: HeleneWestrin Date: Mon, 2 Sep 2024 23:33:13 +0200 Subject: [PATCH 03/13] Added logic for age and order confirmation --- code/favicon.png | Bin 0 -> 11264 bytes code/index.html | 1 + code/script.js | 52 +++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 44 insertions(+), 9 deletions(-) create mode 100644 code/favicon.png diff --git a/code/favicon.png b/code/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..28dfc58af68de66207fb4b7a26c56981df3e6435 GIT binary patch literal 11264 zcmV+bEdSGqP)PyA07*naRCr$PeF=D5)s_G6zNcN5WjkK7?;Dt`mhB`2>X1MhvcOQB&Hyd#Fr~CG zY-NVRzXi8tDWwg8GKErL+G#^e!WxGy>@M3Zpv0KoiU@B`dW|7L)nb4LH) z!34BILK_Ef2NT*j(V5<*H5o9!Uh7<{~{w#;4 z2l5@+R^Kq6B##o9FotoA1~`E>hZ9&iau|aXoH@a`rB_}|ks6P)>=@x+(GLBWgEJo( z@8BFAU}$FqdX9F0HFAanGMD#TMB!kk*K(xb_GWi~)oWS8~jBEyP<11 z6L=ZttV{qamBGg{a2tAd&{UTN2Y7&kbqiqoWbj(X_+~D%&0Qh;;UaTGNZJ4IhQ#Q@ zlBSgEO8kmiS{}*EHZ%VSF0t_pd^G25tSDd%2OG<|Tu5L491zn~pI=%Q10*tY7!w*9 z_&!O-e#ZDd4t9Xae2+J1J(O;{d0GJ4v)o=JOF}6V`9cAh!GR$F8~}^}gf!TFwfg+g z&MX56a=^_v|C}?nPT<0;lEiDXZ*wVYk8?%fN}~t4l!hl@Qww z!n(nX1diiie7g)`oyeuvZMNtO$$>V;_ad~f0 zkZ#2L&)wDxW;R2x+Q10J7Au&=(z62#J?2BI5$7@>b8x>GG6CD`h3xZ!`+eX6+SUEa zZm%;lM&=wZLBQRPn>;(UlDTHu>wMTTOOW~Rz;KQ(Oblh$wL@??AUbovtTqT_I-D>S z6q8r8uZ9@|Ce(%N(-i<9zzgtVh1LZLCns9kdq6+Xza0VwIU8kehxX%^TVYcbAX8qg6W?> z>?8|CtEn{`N0uN5Ly+AakUHAIyF8F-Cl3ab26E1EfP-C?eT#cztm}*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~ioHzo+h9w8Zc}rd#GRw(6?|Iiek_pS8~bTBXA4W|#iZ zeNcLs_pwWpsWIUPxhSeoRmQ*%nP1Jy);z0{wSL_#189}%|L}rYBRq%vZ->0{n3IQK zA~5_L4kZR!w5SsAP6%v1o4&eUC2Re%0;3C* z@jq~a2`WX)_@l5`f5eJc1u}AuUIHqm9{ogV*n@4HQM%N3L|VaRF4E3CczzZ}{;NZ& z`mc%@f{^*8taQz*s`_U-W!!eLU||2X^PCMe9W{YYY2t{>9TBdQudFm-wEsWB`7gl`-90x)2#oz02h6`^OEaF0Sk;jM zbgU9Qu}iNkHeuB0$H72uyhuSE0>__m@W6F!>8^~MP6J(J0Ih)#PYl8977Yi-Q($af zM8k6a78tH!t~G}vYM*HoRstD7hZRwD4HQs=y+UON!t~q;@P!#LM Bella Italia Pizzeria + Date: Mon, 2 Sep 2024 23:51:26 +0200 Subject: [PATCH 04/13] Code improvement --- code/script.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/code/script.js b/code/script.js index 21c96612..4eaa3de9 100644 --- a/code/script.js +++ b/code/script.js @@ -3,7 +3,11 @@ document.addEventListener("DOMContentLoaded", function () { alert(`Welcome to Bella Italia Pizzeria! Click 'OK' to start your order.`); // Step 1 – Ask for name - const userName = prompt("What is your name?"); + let userName = prompt("What is your name?"); + + if (!userName) { + userName = "Anonymous"; + } // Step 2 – Welcome with name + ask for type of food // Using Do...while statement to prompt again if invalid value is entered @@ -118,7 +122,7 @@ document.addEventListener("DOMContentLoaded", function () { let orderConfirmation; do { - if (pizzaSize === "Adult" || pizzaSize === "adult" || pizzaSize === "1") { + if (pizzaSize.toLowerCase() === "adult" || pizzaSize === "1") { orderConfirmation = prompt(`Fantastico ${userName}! Please confirm your order: A delicious ${subFoodSelection} ${foodType} in adult size. @@ -126,11 +130,7 @@ document.addEventListener("DOMContentLoaded", function () { To confirm your order, type 'Yes'. To decline, type anything else. `); - } else if ( - pizzaSize === "Child" || - pizzaSize === "child" || - pizzaSize === "2" - ) { + } else if (pizzaSize.toLowerCase === "child" || pizzaSize === "2") { orderConfirmation = prompt(`Bellissimo ${userName}! Please confirm your order: A perfectly crafted ${subFoodSelection} ${foodType} in child size. From 65b4ab8fcae5819356b8c42d06441d08f19bb6bd Mon Sep 17 00:00:00 2001 From: HeleneWestrin Date: Mon, 2 Sep 2024 23:54:16 +0200 Subject: [PATCH 05/13] Styling --- code/style.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/style.css b/code/style.css index cb38bc19..1801317f 100644 --- a/code/style.css +++ b/code/style.css @@ -20,9 +20,9 @@ body { justify-content: center; align-items: center; flex-direction: column; - min-height: 100vh; + min-height: 100svh; } p { - font-size: 1.5em; + font-size: 1.35em; } From 8a6208da185b7a2fe42d339af5ba552d1c0a6975 Mon Sep 17 00:00:00 2001 From: HeleneWestrin Date: Tue, 3 Sep 2024 10:09:42 +0200 Subject: [PATCH 06/13] Refactor to use button to trigger the flow --- code/index.html | 2 +- code/script.js | 89 +++++++++++++++++++++++++------------------------ code/style.css | 21 ++++++++++-- 3 files changed, 64 insertions(+), 48 deletions(-) diff --git a/code/index.html b/code/index.html index 8bd5dcfd..2395fe5b 100644 --- a/code/index.html +++ b/code/index.html @@ -13,7 +13,7 @@

Bella Itala Pizzeria

-

Place your order here.

+ diff --git a/code/script.js b/code/script.js index 4eaa3de9..83b3362d 100644 --- a/code/script.js +++ b/code/script.js @@ -1,6 +1,7 @@ -document.addEventListener("DOMContentLoaded", function () { +function startOrder() { // Step 1 - Welcome and introduction - alert(`Welcome to Bella Italia Pizzeria! Click 'OK' to start your order.`); + alert(`Benvenuto! Welcome! +Click the button below to begin your order.`); // Step 1 – Ask for name let userName = prompt("What is your name?"); @@ -14,16 +15,15 @@ document.addEventListener("DOMContentLoaded", function () { let foodType; do { foodType = parseInt( - prompt( - `Ciao ${userName} 👋 - What would you like to eat today? - - Enter a number: - 1 – Pizza 🍕 - 2 – Pasta 🍝 - 3 – Salad 🥗 - ` - ) + prompt(` +Ciao ${userName} 👋 +What would you like to eat today? + +Enter a number: + 1 – Pizza 🍕 + 2 – Pasta 🍝 + 3 – Salad 🥗 +`) ); if (foodType === 1) { @@ -46,32 +46,31 @@ document.addEventListener("DOMContentLoaded", function () { if (foodType === "Pizza") { subFoodTypes = `Enter a number: - 1 – Margaritha - 2 – Capricciosa - 3 – Hawaiis`; + 1 – Margaritha + 2 – Capricciosa + 3 – Hawaiis`; } else if (foodType === "Pasta") { subFoodTypes = `Enter a number: - 1 – Carbonara - 2 – Vongole - 3 – Lasagne`; + 1 – Carbonara + 2 – Vongole + 3 – Lasagne`; } else if (foodType === "Salad") { subFoodTypes = `Enter a number: - 1 – Caprese - 2 – Insalata Russa - 3 – Giardiniera`; + 1 – Caprese + 2 – Insalata Russa + 3 – Giardiniera`; } else { subFoodTypes = null; } do { subFoodSelection = parseInt( - prompt( - `${foodType}, what an excellent choice! - What type would you like? - - ${subFoodTypes} - ` - ) + prompt(` +${foodType}, what an excellent choice! +What type would you like? + +${subFoodTypes} +`) ); if (foodType === "Pizza") { @@ -115,7 +114,9 @@ document.addEventListener("DOMContentLoaded", function () { // Step 5 - Age let pizzaSize = prompt( - `Is the pizza for an adult or a child? Please respond with 'adult' or 'child,' or enter 1 for adult and 2 for child.` + `Is the pizza for an adult or a child? + +Respond with 'adult' or 'child,' or enter 1 for adult and 2 for child.` ); // Step 6 - Order confirmation @@ -124,28 +125,28 @@ document.addEventListener("DOMContentLoaded", function () { do { if (pizzaSize.toLowerCase() === "adult" || pizzaSize === "1") { orderConfirmation = prompt(`Fantastico ${userName}! - Please confirm your order: - A delicious ${subFoodSelection} ${foodType} in adult size. - - To confirm your order, type 'Yes'. - To decline, type anything else. - `); - } else if (pizzaSize.toLowerCase === "child" || pizzaSize === "2") { +Please confirm your order: +A delicious ${subFoodSelection} ${foodType} in adult size. + +To confirm your order, type 'Yes'. +To decline, type anything else. + `); + } else if (pizzaSize.toLowerCase() === "child" || pizzaSize === "2") { orderConfirmation = prompt(`Bellissimo ${userName}! - Please confirm your order: - A perfectly crafted ${subFoodSelection} ${foodType} in child size. - - To confirm your order, type 'Yes'. - To decline, type anything else. - `); +Please confirm your order: +A perfectly crafted ${subFoodSelection} ${foodType} in child size. + +To confirm your order, type 'Yes'. +To decline, type anything else. + `); } else { pizzaSize = null; } } while (pizzaSize === null); - if (orderConfirmation === "Yes") { + if (orderConfirmation.toLowerCase() === "yes") { alert(`Splendido ${userName}! Your order is on it's way.`); } else { alert("No worries, hope too see you soon again. Arrivederci!"); } -}); +} diff --git a/code/style.css b/code/style.css index 1801317f..97e74ecb 100644 --- a/code/style.css +++ b/code/style.css @@ -23,6 +23,21 @@ body { min-height: 100svh; } -p { - font-size: 1.35em; -} +button { + all: unset; + cursor: pointer; + color: white; + background-color: black; + font-weight: 500; + padding: 1rem 2rem; + margin-top: 1.5rem; + position: relative; + top: 0; + transition: 0.25s ease; + transition-property: background, top; + + &:hover { + background-color: rgba(0,0,0,0.85); + top: -3px; + } +} \ No newline at end of file From 32e340757ea8737d2522334681631b67b714a205 Mon Sep 17 00:00:00 2001 From: HeleneWestrin Date: Fri, 6 Sep 2024 10:42:15 +0200 Subject: [PATCH 07/13] Changed to ask for age --- .DS_Store | Bin 0 -> 6148 bytes code/.DS_Store | Bin 0 -> 6148 bytes code/script.js | 8 ++++---- 3 files changed, 4 insertions(+), 4 deletions(-) create mode 100644 .DS_Store create mode 100644 code/.DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..0647067d3a4b3d9ddba218a9021dd0b97e5ff93a GIT binary patch literal 6148 zcmeH~F$w}f3`G;&V!>uh%V|7-HyA`u-~|K~8*xF)z$?L_2URHKLJSWDxSmLu%B!J&7q|#Dlq;CI0gn1_$q-1 Dp;i*E literal 0 HcmV?d00001 diff --git a/code/.DS_Store b/code/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 12) { orderConfirmation = prompt(`Fantastico ${userName}! Please confirm your order: A delicious ${subFoodSelection} ${foodType} in adult size. @@ -131,7 +131,7 @@ A delicious ${subFoodSelection} ${foodType} in adult size. To confirm your order, type 'Yes'. To decline, type anything else. `); - } else if (pizzaSize.toLowerCase() === "child" || pizzaSize === "2") { + } else if (Number(pizzaSize) < 12) { orderConfirmation = prompt(`Bellissimo ${userName}! Please confirm your order: A perfectly crafted ${subFoodSelection} ${foodType} in child size. From 837cd136f1b7a49ddff229766768aec14eecd41d Mon Sep 17 00:00:00 2001 From: HeleneWestrin Date: Fri, 6 Sep 2024 10:59:31 +0200 Subject: [PATCH 08/13] Added comments to explain the code better --- code/script.js | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/code/script.js b/code/script.js index 9266d669..c97b9764 100644 --- a/code/script.js +++ b/code/script.js @@ -3,14 +3,15 @@ function startOrder() { alert(`Benvenuto! Welcome! Click the button below to begin your order.`); - // Step 1 – Ask for name + // Step 2 – Ask the user for their name const userName = prompt("What is your name?"); + // If no name is provided (= the user clicks Cancel), assign Anonynous if (!userName) { userName = "Anonymous"; } - // Step 2 – Welcome with name + ask for type of food + // Step 3 – Welcome with their name + Ask for the type of food they want to order // Using Do...while statement to prompt again if invalid value is entered let foodType; do { @@ -26,6 +27,7 @@ Enter a number: `) ); + // Assign the appropriate food type based on the user's input if (foodType === 1) { foodType = "Pizza"; } else if (foodType === 2) { @@ -33,17 +35,19 @@ Enter a number: } else if (foodType === 3) { foodType = "Salad"; } else { + // Alert the user if an invalid selection was made foodType = null; alert( "Sorry, that's not on the menu today. Please type 1, 2 or 3 to make your selection." ); } - } while (foodType === null); + } while (foodType === null); // Keep asking until a valid option is chosen - // Step 3 - Subtype choice + // Step 4 - Ask for the specific type of food within the chosen category let subFoodTypes; let subFoodSelection; + // Set the sub-food options based on the selected food type if (foodType === "Pizza") { subFoodTypes = `Enter a number: 1 – Margaritha @@ -63,6 +67,7 @@ Enter a number: subFoodTypes = null; } + // Use another do...while loop to get valid input for sub-food selection do { subFoodSelection = parseInt( prompt(` @@ -73,6 +78,7 @@ ${subFoodTypes} `) ); + // Assign the sub-food based on user's input if (foodType === "Pizza") { if (subFoodSelection === 1) { subFoodSelection = "Margaritha"; @@ -105,25 +111,27 @@ ${subFoodTypes} } } + // Alert the user if they make an invalid sub-food selection if (subFoodSelection === null) { alert( "We're all out of that for today I'm afraid. Please type 1, 2 or 3 to make your selection." ); } - } while (subFoodSelection === null); + } while (subFoodSelection === null); // Keep asking until a valid selection is made - // Step 5 - Age + // Step 5 - Ask for the user's age to determine the portion size let pizzaSize = prompt( `Is the pizza for an adult or a child? Please enter your age.` ); - // Step 6 - Order confirmation + // Step 6 - Confirm the order details and ask for confirmation let orderConfirmation; do { if (Number(pizzaSize) > 12) { + // Confirm adult-sized order if age is higher than 12 orderConfirmation = prompt(`Fantastico ${userName}! Please confirm your order: A delicious ${subFoodSelection} ${foodType} in adult size. @@ -132,6 +140,7 @@ To confirm your order, type 'Yes'. To decline, type anything else. `); } else if (Number(pizzaSize) < 12) { + // Confirm child-sized order if age is lower than 12 orderConfirmation = prompt(`Bellissimo ${userName}! Please confirm your order: A perfectly crafted ${subFoodSelection} ${foodType} in child size. @@ -140,10 +149,12 @@ To confirm your order, type 'Yes'. To decline, type anything else. `); } else { + // Prompt again if age input is invalid pizzaSize = null; } - } while (pizzaSize === null); + } while (pizzaSize === null); // Keep asking until valid input is given + // Step 7 - Final message based on confirmation if (orderConfirmation.toLowerCase() === "yes") { alert(`Splendido ${userName}! Your order is on it's way.`); } else { From 62013f80af744ccbe4f70a665ef4d559fd47c25c Mon Sep 17 00:00:00 2001 From: HeleneWestrin Date: Sat, 7 Sep 2024 23:52:03 +0200 Subject: [PATCH 09/13] Added switch js version and logic for when user cancels the order --- code/index.html | 2 +- code/script.js | 38 ++++++--- code/switch.js | 203 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 230 insertions(+), 13 deletions(-) create mode 100644 code/switch.js diff --git a/code/index.html b/code/index.html index 2395fe5b..89466830 100644 --- a/code/index.html +++ b/code/index.html @@ -14,6 +14,6 @@

Bella Itala Pizzeria

- + diff --git a/code/script.js b/code/script.js index c97b9764..e1d1e932 100644 --- a/code/script.js +++ b/code/script.js @@ -4,7 +4,7 @@ function startOrder() { Click the button below to begin your order.`); // Step 2 – Ask the user for their name - const userName = prompt("What is your name?"); + let userName = prompt("What is your name?"); // If no name is provided (= the user clicks Cancel), assign Anonynous if (!userName) { @@ -15,8 +15,7 @@ Click the button below to begin your order.`); // Using Do...while statement to prompt again if invalid value is entered let foodType; do { - foodType = parseInt( - prompt(` + let foodInput = prompt(` Ciao ${userName} 👋 What would you like to eat today? @@ -24,8 +23,16 @@ Enter a number: 1 – Pizza 🍕 2 – Pasta 🍝 3 – Salad 🥗 -`) - ); +`); + + // If user clicks cancel abort the order process + if (foodInput === null) { + alert("You cancelled the order. Goodbye!"); + return; + } + + // Parse the user's input + foodType = parseInt(foodInput); // Assign the appropriate food type based on the user's input if (foodType === 1) { @@ -52,12 +59,12 @@ Enter a number: subFoodTypes = `Enter a number: 1 – Margaritha 2 – Capricciosa - 3 – Hawaiis`; + 3 – Hawaii`; } else if (foodType === "Pasta") { subFoodTypes = `Enter a number: 1 – Carbonara 2 – Vongole - 3 – Lasagne`; + 3 – Lasagna`; } else if (foodType === "Salad") { subFoodTypes = `Enter a number: 1 – Caprese @@ -69,14 +76,21 @@ Enter a number: // Use another do...while loop to get valid input for sub-food selection do { - subFoodSelection = parseInt( - prompt(` + let subFoodInput = prompt(` ${foodType}, what an excellent choice! What type would you like? ${subFoodTypes} -`) - ); + `); + + // If user clicks cancel abort the order process + if (subFoodInput === null) { + alert("You cancelled the order. Goodbye!"); + return; + } + + // Parse the user's input + subFoodSelection = parseInt(subFoodInput); // Assign the sub-food based on user's input if (foodType === "Pizza") { @@ -130,7 +144,7 @@ Please enter your age.` let orderConfirmation; do { - if (Number(pizzaSize) > 12) { + if (Number(pizzaSize) >= 12) { // Confirm adult-sized order if age is higher than 12 orderConfirmation = prompt(`Fantastico ${userName}! Please confirm your order: diff --git a/code/switch.js b/code/switch.js new file mode 100644 index 00000000..4767a313 --- /dev/null +++ b/code/switch.js @@ -0,0 +1,203 @@ +function startOrder() { + // Step 1 - Welcome and introduction + alert(`Benvenuto! Welcome! +Click the button below to begin your order.`); + + // Step 2 – Ask the user for their name + let userName = prompt("What is your name?"); + + // If no name is provided (= the user clicks Cancel), assign Anonynous + if (!userName) { + userName = "Anonymous"; + } + + // Step 3 – Welcome with their name + Ask for the type of food they want to order + // Using Do...while statement to prompt again if invalid value is entered + let foodType; + do { + let foodInput = prompt(` +Ciao ${userName} 👋 +What would you like to eat today? + +Enter a number: + 1 – Pizza 🍕 + 2 – Pasta 🍝 + 3 – Salad 🥗 +`); + + // If user clicks cancel abort the order process + if (foodInput === null) { + alert("You cancelled the order. Goodbye!"); + return; + } + + // Parse the user's input + foodType = Number(foodInput); + + // Assign the appropriate food type based on the user's input + switch (foodType) { + case 1: + foodType = "Pizza"; + break; + case 2: + foodType = "Pasta"; + break; + case 3: + foodType = "Salad"; + break; + default: + foodType = null; + alert( + "Sorry, that's not on the menu today. Please type 1, 2 or 3 to make your selection." + ); + } + } while (foodType === null); // Keep asking until a valid option is chosen + + // Step 4 - Ask for the specific type of food within the chosen category + let subFoodTypes; + let subFoodSelection; + + // Set the sub-food options based on the selected food type + switch (foodType) { + case "Pizza": + subFoodTypes = `Enter a number: + 1 – Margaritha + 2 – Capricciosa + 3 – Hawaii`; + break; + + case "Pasta": + subFoodTypes = `Enter a number: + 1 – Carbonara + 2 – Vongole + 3 – Lasagna`; + break; + + case "Salad": + subFoodTypes = `Enter a number: + 1 – Caprese + 2 – Insalata Russa + 3 – Giardiniera`; + break; + + default: + subFoodTypes = null; + } + + // Use another do...while loop to get valid input for sub-food selection + do { + let subFoodInput = prompt(` +${foodType}, what an excellent choice! +What type would you like? + +${subFoodTypes} +`); + + // If user clicks cancel abort the order process + if (subFoodInput === null) { + alert("You cancelled the order. Goodbye!"); + return; + } + + // Parse the user's input + subFoodSelection = Number(subFoodInput); + + // Assign the sub-food based on user's input + switch (foodType) { + case "Pizza": + switch (subFoodSelection) { + case 1: + subFoodSelection = "Margaritha"; + break; + case 2: + subFoodSelection = "Capricciosa"; + break; + case 3: + subFoodSelection = "Hawaii"; + break; + default: + subFoodSelection = null; + } + break; + case "Pasta": + switch (subFoodSelection) { + case 1: + subFoodSelection = "Carbonara"; + break; + case 2: + subFoodSelection = "Spaghetti Alle Vongole"; + break; + case 3: + subFoodSelection = "Lasagne"; + break; + default: + subFoodSelection = null; + } + break; + case "Salad": + switch (subFoodSelection) { + case 1: + subFoodSelection = "Caprese"; + break; + case 2: + subFoodSelection = "Insalata Russa"; + break; + case 3: + subFoodSelection = "Giardiniera"; + break; + default: + subFoodSelection = null; + } + break; + } + + // Alert the user if they make an invalid sub-food selection + if (subFoodSelection === null) { + alert( + "We're all out of that for today I'm afraid. Please type 1, 2 or 3 to make your selection." + ); + } + } while (subFoodSelection === null); // Keep asking until a valid selection is made + + // Step 5 - Ask for the user's age to determine the portion size + let pizzaSize = prompt( + `Is the pizza for an adult or a child? + +Please enter your age.` + ); + + // Step 6 - Confirm the order details and ask for confirmation + let orderConfirmation; + + do { + if (Number(pizzaSize) >= 12) { + // Confirm adult-sized order if age is equal or higher than 12 + orderConfirmation = prompt(`Fantastico ${userName}! +Please confirm your order: +A delicious ${subFoodSelection} ${foodType} in adult size. + +To confirm your order, type 'Yes'. +To decline, type anything else. + `); + } else if (Number(pizzaSize) < 12) { + // Confirm child-sized order if age is lower than 12 + orderConfirmation = prompt(`Bellissimo ${userName}! +Please confirm your order: +A perfectly crafted ${subFoodSelection} ${foodType} in child size. + +To confirm your order, type 'Yes'. +To decline, type anything else. + `); + } else { + // Prompt again if age input is invalid + pizzaSize = null; + } + } while (pizzaSize === null); // Keep asking until valid input is given + + // Step 7 - Final message based on confirmation + if (orderConfirmation.toLowerCase() === "yes") { + alert(`Splendido ${userName}! Your order is on it's way.`); + } else { + alert("No worries, hope too see you soon again. Arrivederci!"); + } +} From 551e0d1c39bbe30f05d7eec0b272ff7ec1a895e0 Mon Sep 17 00:00:00 2001 From: HeleneWestrin Date: Sat, 7 Sep 2024 23:53:10 +0200 Subject: [PATCH 10/13] Spelling correction --- code/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/index.html b/code/index.html index 89466830..c792f661 100644 --- a/code/index.html +++ b/code/index.html @@ -12,7 +12,7 @@ /> -

Bella Itala Pizzeria

+

Bella Italia Pizzeria

From b4d1056302b9121599e24a6ed99a272d8487c5df Mon Sep 17 00:00:00 2001 From: HeleneWestrin Date: Sat, 7 Sep 2024 23:59:37 +0200 Subject: [PATCH 11/13] Updated README file --- README.md | 6 ++++-- pull_request_template.md | 6 ------ 2 files changed, 4 insertions(+), 8 deletions(-) delete mode 100644 pull_request_template.md diff --git a/README.md b/README.md index 8c3533dc..bdf3dea6 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,10 @@ The task is to create a order functionality for a fictional pizzeria using JavaS ## The problem -Describe how you approached to problem, and what tools and techniques you used to solve it. How did you plan? What technologies did you use? If you had more time, what would be next? +I started with the basic logic and tried to get that to work. After that was working I started looking into how I could improve my code. I wanted to make sure the prompt asked again when the user had an invalid option and also that it would stop executing the code if the user clicked "Cancel". + +I also did the stretch goals and did a version where I use 'switch' instead of if/else statements. ## View it live -Have you deployed your project somewhere? Be sure to include the link to the deployed project so that the viewer can click around and see what it's all about +[View it live here »](https://bellaitaliapizzeria.netlify.app/) diff --git a/pull_request_template.md b/pull_request_template.md deleted file mode 100644 index e239e19f..00000000 --- a/pull_request_template.md +++ /dev/null @@ -1,6 +0,0 @@ -## Netlify link -Add your Netlify link here like this (update with the correct one): - -https://my-netlify-link.netlify.app - -PS. Don't forget to add it in your readme as well. From bc84531b8170193ba961a5c3c3977742a07c6cc8 Mon Sep 17 00:00:00 2001 From: HeleneWestrin Date: Mon, 9 Sep 2024 09:21:59 +0200 Subject: [PATCH 12/13] Small update --- code/script.js | 4 ++-- code/switch.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/code/script.js b/code/script.js index e1d1e932..1d8b4cbf 100644 --- a/code/script.js +++ b/code/script.js @@ -1,4 +1,4 @@ -function startOrder() { +const startOrder = () => { // Step 1 - Welcome and introduction alert(`Benvenuto! Welcome! Click the button below to begin your order.`); @@ -174,4 +174,4 @@ To decline, type anything else. } else { alert("No worries, hope too see you soon again. Arrivederci!"); } -} +}; diff --git a/code/switch.js b/code/switch.js index 4767a313..900b24aa 100644 --- a/code/switch.js +++ b/code/switch.js @@ -1,4 +1,4 @@ -function startOrder() { +const startOrder = () => { // Step 1 - Welcome and introduction alert(`Benvenuto! Welcome! Click the button below to begin your order.`); @@ -200,4 +200,4 @@ To decline, type anything else. } else { alert("No worries, hope too see you soon again. Arrivederci!"); } -} +}; From c1d024931a8d80a4a407ee727b134b22ee36f790 Mon Sep 17 00:00:00 2001 From: HeleneWestrin Date: Mon, 9 Sep 2024 12:40:35 +0200 Subject: [PATCH 13/13] Added empty value to my variables --- .vscode/settings.json | 3 +++ code/script.js | 8 ++++---- code/switch.js | 8 ++++---- 3 files changed, 11 insertions(+), 8 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..6b665aaa --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "liveServer.settings.port": 5501 +} diff --git a/code/script.js b/code/script.js index 1d8b4cbf..8ca9f75e 100644 --- a/code/script.js +++ b/code/script.js @@ -13,7 +13,7 @@ Click the button below to begin your order.`); // Step 3 – Welcome with their name + Ask for the type of food they want to order // Using Do...while statement to prompt again if invalid value is entered - let foodType; + let foodType = ""; do { let foodInput = prompt(` Ciao ${userName} 👋 @@ -51,8 +51,8 @@ Enter a number: } while (foodType === null); // Keep asking until a valid option is chosen // Step 4 - Ask for the specific type of food within the chosen category - let subFoodTypes; - let subFoodSelection; + let subFoodTypes = ""; + let subFoodSelection = ""; // Set the sub-food options based on the selected food type if (foodType === "Pizza") { @@ -141,7 +141,7 @@ Please enter your age.` ); // Step 6 - Confirm the order details and ask for confirmation - let orderConfirmation; + let orderConfirmation = ""; do { if (Number(pizzaSize) >= 12) { diff --git a/code/switch.js b/code/switch.js index 900b24aa..6ae08694 100644 --- a/code/switch.js +++ b/code/switch.js @@ -13,7 +13,7 @@ Click the button below to begin your order.`); // Step 3 – Welcome with their name + Ask for the type of food they want to order // Using Do...while statement to prompt again if invalid value is entered - let foodType; + let foodType = ""; do { let foodInput = prompt(` Ciao ${userName} 👋 @@ -54,8 +54,8 @@ Enter a number: } while (foodType === null); // Keep asking until a valid option is chosen // Step 4 - Ask for the specific type of food within the chosen category - let subFoodTypes; - let subFoodSelection; + let subFoodTypes = ""; + let subFoodSelection = ""; // Set the sub-food options based on the selected food type switch (foodType) { @@ -167,7 +167,7 @@ Please enter your age.` ); // Step 6 - Confirm the order details and ask for confirmation - let orderConfirmation; + let orderConfirmation = ""; do { if (Number(pizzaSize) >= 12) {