From 912c66b83346f8c0abd1754c4857307072e602cb Mon Sep 17 00:00:00 2001 From: smily342 Date: Thu, 5 Sep 2024 19:17:44 +0200 Subject: [PATCH 1/3] test.txt --- test.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 test.txt diff --git a/test.txt b/test.txt new file mode 100644 index 00000000..9daeafb9 --- /dev/null +++ b/test.txt @@ -0,0 +1 @@ +test From e8913019388ae4300b9dabb24e6cd21585d7ebdf Mon Sep 17 00:00:00 2001 From: smily342 Date: Sat, 7 Sep 2024 16:13:48 +0200 Subject: [PATCH 2/3] =?UTF-8?q?Ajout=20de=20l'=C3=A9tape=204=20pour=20g?= =?UTF-8?q?=C3=A9rer=20l'=C3=A2ge=20et=20le=20co=C3=BBt=20des=20repas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Echo.txt | 1 + code/index.html | 34 +++++++++++++------------- code/script.js | 64 ++++++++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 80 insertions(+), 19 deletions(-) create mode 100644 Echo.txt diff --git a/Echo.txt b/Echo.txt new file mode 100644 index 00000000..9e018b37 --- /dev/null +++ b/Echo.txt @@ -0,0 +1 @@ +test \ No newline at end of file diff --git a/code/index.html b/code/index.html index f7844d6b..2030bff0 100644 --- a/code/index.html +++ b/code/index.html @@ -1,18 +1,20 @@ - - - - Javascript Pizzeria - - - - -

Javascript Pizzeria

-

Logic is executed automatically

- - - + + + + + Javascript Pizzeria + + + + + +

Javascript Pizzeria

+

Logic is executed automatically

+ + + + \ No newline at end of file diff --git a/code/script.js b/code/script.js index 34ca0f34..deff9789 100644 --- a/code/script.js +++ b/code/script.js @@ -2,15 +2,73 @@ // Step 1 - Welcome and introduction // Your code goes here -alert( - `Welcome to our Javascript Pizzeria. Ready to Start? - Click 'OK' to begin.` -) + + +// This part is the welcome for the customer +alert("Welcome to our Javascript Pizza!"); + +let userName = prompt ("What's your name ?") +alert("Hello, " + userName + " !"); + // Step 2 - Food choice // Your code goes here +// Choice of the foods" + +// let foodChoice let the customer chose his meal before giving a second choice +// we use if to cover all the options + +let foodChoice = prompt("What would you like to order ? Select a number :\n1. Pizza\n2. Pasta\n3. Salad"); +if (foodChoice == 1) { + alert("you've chosen a Pizza."); +} else if (foodChoice == 2) { + alert("you've chosen some Pastas."); +} else if (foodChoice == 3) { + alert("you've chosen some Salads."); +} else { + alert("Invalid Choice."); +} + // Step 3 - Subtype choice // Your code goes here +if (foodChoice == 1){ + let pizzaType = prompt ("Which pizza would you like ?\n1. Margherita\n2. Pepperoni\n3. 4 cheeses"); + if (pizzaType == 1) { + alert("You've chosen a Margherita Pizza ."); +} else if (pizzaType == 2) { + alert("You've chosen a Pepperoni Pizza ."); +} else if (pizzaType == 3) { + alert("You've chosen a 4 Cheeses Pizza."); +} else { + alert("Invalid Choice."); +} +} +if (foodChoice == 2) { + let pastaType = prompt("Which type of pasta would you like?\n1. Carbonara\n2. Bolognese\n3. Pesto"); + if (pastaType == 1) { + alert("You've chosen Carbonara Pasta."); + } else if (pastaType == 2) { + alert("You've chosen Bolognese Pasta."); + } else if (pastaType == 3) { + alert("You've chosen Pesto Pasta."); + } else { + alert("Invalid Choice."); + if (foodChoice == 3) { + let saladType = prompt("Which type of salad would you like?\n1. Caesar\n2. Greek\n3. Niçoise"); + if (saladType == 1) { + alert("You've chosen a Caesar Salad."); + } else if (saladType == 2) { + alert("You've chosen a Greek Salad."); + } else if (saladType == 3) { + alert("You've chosen a Niçoise Salad."); + } else { + alert("Invalid Choice."); + } + } + } +} + // Step 4 - Age // Your code goes here From d5dfb0c14686300f43770c25701204099d688dfb Mon Sep 17 00:00:00 2001 From: smily342 Date: Sat, 7 Sep 2024 16:56:14 +0200 Subject: [PATCH 3/3] final push step 5 --- code/script.js | 96 ++++++++++++++++++++++++++++---------------------- 1 file changed, 54 insertions(+), 42 deletions(-) diff --git a/code/script.js b/code/script.js index deff9789..5727cf3c 100644 --- a/code/script.js +++ b/code/script.js @@ -1,49 +1,42 @@ -// Start here - // Step 1 - Welcome and introduction -// Your code goes here - -// This part is the welcome for the customer -alert("Welcome to our Javascript Pizza!"); +//Loop until a name is given +let userName = ""; +while (!userName) { + userName = prompt("What's your name? Please enter your name:"); +} -let userName = prompt ("What's your name ?") +// Afficher un message de bienvenue une fois que le nom est entré alert("Hello, " + userName + " !"); - - // Step 2 - Food choice -// Your code goes here -// Choice of the foods" - -// let foodChoice let the customer chose his meal before giving a second choice -// we use if to cover all the options - let foodChoice = prompt("What would you like to order ? Select a number :\n1. Pizza\n2. Pasta\n3. Salad"); + if (foodChoice == 1) { - alert("you've chosen a Pizza."); + alert("You've chosen a Pizza."); } else if (foodChoice == 2) { - alert("you've chosen some Pastas."); + alert("You've chosen some Pasta."); } else if (foodChoice == 3) { - alert("you've chosen some Salads."); + alert("You've chosen a Salad."); } else { alert("Invalid Choice."); } - // Step 3 - Subtype choice -// Your code goes here -if (foodChoice == 1){ - let pizzaType = prompt ("Which pizza would you like ?\n1. Margherita\n2. Pepperoni\n3. 4 cheeses"); +// Subtype for Pizza +if (foodChoice == 1) { + let pizzaType = prompt("Which pizza would you like ?\n1. Margherita\n2. Pepperoni\n3. 4 cheeses"); if (pizzaType == 1) { - alert("You've chosen a Margherita Pizza ."); -} else if (pizzaType == 2) { - alert("You've chosen a Pepperoni Pizza ."); -} else if (pizzaType == 3) { + alert("You've chosen a Margherita Pizza."); + } else if (pizzaType == 2) { + alert("You've chosen a Pepperoni Pizza."); + } else if (pizzaType == 3) { alert("You've chosen a 4 Cheeses Pizza."); -} else { + } else { alert("Invalid Choice."); + } } -} + +// Subtype for Pasta if (foodChoice == 2) { let pastaType = prompt("Which type of pasta would you like?\n1. Carbonara\n2. Bolognese\n3. Pesto"); if (pastaType == 1) { @@ -54,24 +47,43 @@ if (foodChoice == 2) { alert("You've chosen Pesto Pasta."); } else { alert("Invalid Choice."); - if (foodChoice == 3) { - let saladType = prompt("Which type of salad would you like?\n1. Caesar\n2. Greek\n3. Niçoise"); - if (saladType == 1) { - alert("You've chosen a Caesar Salad."); - } else if (saladType == 2) { - alert("You've chosen a Greek Salad."); - } else if (saladType == 3) { - alert("You've chosen a Niçoise Salad."); - } else { - alert("Invalid Choice."); - } - } } } +// Subtype for Salad +if (foodChoice == 3) { + let saladType = prompt("Which type of salad would you like?\n1. Caesar\n2. Greek\n3. Niçoise"); + if (saladType == 1) { + alert("You've chosen a Caesar Salad."); + } else if (saladType == 2) { + alert("You've chosen a Greek Salad."); + } else if (saladType == 3) { + alert("You've chosen a Niçoise Salad."); + } else { + alert("Invalid Choice."); + } +} // Step 4 - Age -// Your code goes here +// Asking if the order is for an Adult or A child, the user must enter his age +let ageGroup = prompt("Is the meal for a child or an adult? What's your age ?"); + +// Déclaration des prix +let finalPrice; +if (ageGroup >= 18) { + // Adult + finalPrice = 10; // Prix pour un adulte + alert("You've selected a meal for an adult. The price is " + finalPrice + " CHF."); +} else { + // Minor + finalPrice = 7; // Prix pour un enfant + alert("You've selected a meal for a child. The price is " + finalPrice + " CHF."); +} // Step 5 - Order confirmation -// Your code goes here +let confirmation = prompt("Would you like to confirm your order? Type 'yes' or 'no'."); +if (confirmation.toLowerCase() == 'yes') { + alert("Thank you! Your meal will be prepared shortly. The total cost is " + finalPrice + " CHF."); +} else { + alert("We hope to see you again soon!"); +}