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 Emelie Kedert #137

Open
wants to merge 6 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
Binary file added .DS_Store
Binary file not shown.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# Project Name

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.
In this weeks project I was tasked with creating a simple interactive webpage using JavaScript, beginning with displaying a welcome message using the alert() method. Follow the provided steps in the script.js file to guide me through the process of building the project.

## 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?
To approach this problem, I began by carefully reading the provided instructions and analyzing the steps outlined in the script.js file. My initial focus was on understanding how to use the alert() and prompt() method in JavaScript to display messages and store input from a user on the webpage.

For planning, I followed the sequential steps outlined in the script.js file, breaking down the task into manageable parts. The primary technologies used were JavaScript for adding interactivity with the alert() and prompt() method. If I had more time, my next steps would ipotentially br adding more dynamic elements using JavaScript event listeners and DOM manipulation.

I also made the strech goals, and in the switch.js file I tried out using ";". And I think I like to use ";" more than not to use them.

## 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
https://project-pizza-ek.netlify.app
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>
153 changes: 147 additions & 6 deletions code/script.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,160 @@
// Start here

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

let userName = prompt(
`What is your name?`
)

alert(
`Hello ${userName}!`
)

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

let foodName

if (foodChoice === `1`) {
foodName = `Pizza`
} else if (foodChoice === `2`) {
foodName = `Pasta`
} else if (foodChoice === `3`) {
foodName = `Salad`
} else {
foodName = `no food`
}

alert(
`You have chosen ${foodName}. Yum!`
)

// Step 3 - Subtype choice
// Your code goes here
let subType

if (foodChoice === `1`) {
subType = prompt(
`What kind of Pizza would you like to order?
Enter a number:
1 - Margeritha
2 - Napolitana
3 - Bussola
`
)

if (subType === `1`) {
subType = `Margeritha`
} else if (subType === `2`) {
subType = `Napolitana`
} else if (subType === `3`) {
subType = `Bussola`
} else {
subType = `no food`
}

} else if (foodChoice === `2`) {
subType = prompt(
`What kind of Pasta would you like to order?
Enter a number:
1 - Arrabiata
2 - Garlic
3 - Meat and sauce
`
)

if (subType === `1`) {
subType = `Arrabiata`
} else if (subType === `2`) {
subType = `Garlic`
} else if (subType === `3`) {
subType = `Meat and sauce`
} else {
subType = `no food`
}

} else if (foodChoice === `3`) {
subType = prompt(
`What kind of Salad would you like to order?
Enter a number:
1 - Tuna
2 - Ham and cheese
3 - Veggi
`
)

if (subType === `1`) {
subType = `Tuna`
} else if (subType === `2`) {
subType = `Ham and cheese`
} else if (subType === `3`) {
subType = `Veggi`
} else {
subType = `no food`
}

} else {
subType = `no food`
}

alert(
`You have chosen ${subType}. Yum!`
)

// Step 4 - Age
// Your code goes here
let userAge = prompt(
`Is this food for a child or an adult?
Please type your age:`
)

//Step 5 - Order confirmation
let confirmation

if (userAge <= 12) {
confirmation = prompt(
`You'd like to order a child portion of ${subType}.
- price $7

Are you sure you want to order this?
Enter a number to confirm:
1 - Yes
2 - No
`
)

} else {
confirmation = prompt(
`You'd like to order an adult portion of ${subType}.
- price $10

Are you sure you want to order this?
Enter a number to confirm:
1 - Yes
2 - No
`
)
}

if (confirmation === `1`) {
alert(
`Thank you for your order, your food is now being prepared`
)
} else if (confirmation === `2`) {
alert(
`Your order has been canceled, please return for future orders`
)

// Step 5 - Order confirmation
// Your code goes here
} else {
alert(
`Your order has ben canceled due to a type error, please return for future orders`
)
}
160 changes: 160 additions & 0 deletions code/switch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
// Step 1 - Welcome and introduction
alert(`Welcome to our Javascript Pizzeria. Ready to Start? - Click 'OK' to begin.`);

let userName = prompt(`What is your name?`);
alert(`Hello ${userName}!`);

// Step 2 - Food choice
let foodChoice = prompt(
`What kind of food would you like to order?
Enter a number:
1 - Pizza
2 - Pasta
3 - Salad
`
);

let foodName;

switch (foodChoice) {
case `1`:
foodName = `Pizza`;
break;
case `2`:
foodName = `Pasta`;
break;
case `3`:
foodName = `Salad`;
break;
default:
foodName = `no food`;
}

alert(`You have chosen ${foodName}. Yum!`);

// Step 3 - Subtype choice
let subType;

switch (foodChoice) {
case `1`:
subType = prompt(
`What kind of Pizza would you like to order?
Enter a number:
1 - Margherita
2 - Napolitana
3 - Bussola
`
);

switch (subType) {
case `1`:
subType = `Margherita`;
break;
case `2`:
subType = `Napolitana`;
break;
case `3`:
subType = `Bussola`;
break;
default:
subType = `no food`;
}
break;

case `2`:
subType = prompt(
`What kind of Pasta would you like to order?
Enter a number:
1 - Arrabiata
2 - Garlic
3 - Meat and sauce
`
);

switch (subType) {
case `1`:
subType = `Arrabiata`;
break;
case `2`:
subType = `Garlic`;
break;
case `3`:
subType = `Meat and sauce`;
break;
default:
subType = `no food`;
}
break;

case `3`:
subType = prompt(
`What kind of Salad would you like to order?
Enter a number:
1 - Tuna
2 - Ham and cheese
3 - Veggi
`
);

switch (subType) {
case `1`:
subType = `Tuna`;
break;
case `2`:
subType = `Ham and cheese`;
break;
case `3`:
subType = `Veggi`;
break;
default:
subType = `no food`;
}
break;

default:
subType = `no food`;
}

alert(`You have chosen ${subType}. Yum!`);

// Step 4 - Age
let userAge = prompt(`Is this food for a child or an adult? Please type your age:`);

// Step 5 - Order confirmation
let confirmation;

if (userAge <= 12) {
confirmation = prompt(
`You'd like to order a child portion of ${subType}.
- price $7

Are you sure you want to order this?
Enter a number to confirm:
1 - Yes
2 - No
`
);
} else {
confirmation = prompt(
`You'd like to order an adult portion of ${subType}.
- price $10

Are you sure you want to order this?
Enter a number to confirm:
1 - Yes
2 - No
`
);
}

// Switch for confirmation
switch (confirmation) {
case `1`:
alert(`Thank you for your order, your food is now being prepared`);
break;
case `2`:
alert(`Your order has been canceled, please return for future orders`);
break;
default:
alert(`Your order has been canceled due to a type error, please return for future orders`);
}