Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pizza Project pull #151

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
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
1 change: 1 addition & 0 deletions Echo.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test
Copy link
Contributor

Choose a reason for hiding this comment

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

Practicing terminal commands? 😄 Remove any files you're not using before handing in

34 changes: 18 additions & 16 deletions code/index.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
<!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>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>
90 changes: 80 additions & 10 deletions code/script.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,89 @@
// Start here

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

//Loop until a name is given
let userName = "";
while (!userName) {
userName = prompt("What's your name? Please enter 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
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 Pasta.");
} else if (foodChoice == 3) {
alert("You've chosen a Salad.");
} else {
alert("Invalid Choice.");
}

// Step 3 - Subtype choice
// Your code goes here
// 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 4 Cheeses Pizza.");
} 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) {
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.");
}
}

// 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') {
Copy link
Contributor

Choose a reason for hiding this comment

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

Excellent!

alert("Thank you! Your meal will be prepared shortly. The total cost is " + finalPrice + " CHF.");
} else {
alert("We hope to see you again soon!");
}
1 change: 1 addition & 0 deletions test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test