-
Notifications
You must be signed in to change notification settings - Fork 175
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
Week 4: Pizzabot #139
Open
jacquelinekellyhunt
wants to merge
3
commits into
Technigo:main
Choose a base branch
from
jacquelinekellyhunt:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Week 4: Pizzabot #139
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
# 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. | ||
This project is a small introduction to a JavaScript language. This Pizzeria Ordering System is an interactive web-based application that guides "clients" through customising their food order. It prompts users to input their name, choose between pizza, pasta, or salad, and select specific dish types like Margherita or Caesar Salad. The system also requests the user's age to determine whether to prepare a child-sized or adult-sized portion, then asks for final order confirmation using "Yes" or "No." The project demonstrates basic JavaScript functions, input handling, and conditional logic. | ||
|
||
## 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 implement the system, I used vanilla JavaScript, focusing on the use of prompt() and alert() for user interaction. The logic was built using functions and conditional statements (such as if/else) to control the flow based on user inputs. I structured the project around functions to modularise different tasks like selecting food type and confirming the order, ensuring the program remained organised and easy to follow (which was A struggle). | ||
If I had more time, I would enhance the project by adding error handling for invalid inputs, refining the UI to replace the basic prompt() and alert() boxes with more visually appealing forms, and perhaps implementing a responsive design using HTML and CSS. | ||
|
||
## 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://pizzzabot.netlify.app |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,131 @@ | ||
// Start here | ||
|
||
// 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 our Javascript Pizzeria. Ready to Start? - Click 'OK' to begin."); | ||
|
||
// Ask for the user's name and store the answer in a variable | ||
const userName = prompt("Please insert your name for the Pizzeria to remember your order :)"); | ||
|
||
// Greet the user with their name | ||
alert("Hi, " + userName + "! Thanks for taking an order from our Javascript Pizzeria."); | ||
|
||
// Declare variables for foodType and chosenSubtype globally | ||
|
||
|
||
// Step 2 - activating the choosingFood function | ||
choosingFood(); | ||
|
||
// Function to ask for food type | ||
function QuestionFoodtype() { | ||
const foodChoice = prompt("Please let us know which type of dish you would like to order. Please write a number:\n1 - Pizza\n2 - Pasta \n3 - Salad"); | ||
return parseInt(foodChoice); | ||
} | ||
|
||
//for the function to loop properly I have built 2 separate functions - one for the question, where the client orders the number from the menu and - second for the process of the answers, whether the client has inserted a correct menu number or not - thus looping the function | ||
function choosingFood() { | ||
foodType = QuestionFoodtype(); | ||
|
||
if (foodType === 1) { | ||
foodTypeName = "Pizza"; | ||
alert("Great, thank you! You've chosen a Pizza!"); | ||
} | ||
else if (foodType === 2) { | ||
foodTypeName = "Pasta"; | ||
alert("Great, thank you! You've chosen a Pasta!"); | ||
} | ||
else if (foodType === 3) { | ||
foodTypeName = "Salad"; | ||
alert("Great, thank you! You've chosen a Salad!"); | ||
} | ||
else { | ||
alert("Unfortunately, we don't have that type of dish, please try again!"); | ||
choosingFood(); | ||
return; | ||
} | ||
|
||
QuestionSubFoodType(foodType); | ||
} | ||
|
||
//at this point of process, we know what type of menu item the client has chosen | ||
//Step 3 - now asking the type of dish | ||
function QuestionSubFoodType(foodType) { | ||
let subtype; | ||
|
||
if (foodType === 1) { | ||
subtype = prompt("What type of pizza would you like?\n1 - Margharita\n2 - Pepperoni\n3 - Hawaiian"); | ||
} | ||
else if (foodType === 2) { | ||
subtype = prompt("What type of pasta would you like?\n1 - Bolognese\n2 - Crema di pollo\n3 - Pesto"); | ||
} | ||
else if (foodType === 3) { | ||
subtype = prompt("What type of salad would you like?\n1 - Caesar\n2 - Greek\n3 - Mozzarella"); | ||
} | ||
|
||
//from this point, we now know everything the client has chosen from the menu - the food dish and the type of dish | ||
if (foodType === 1) { | ||
if (subtype === "1") { | ||
chosenSubtype = "Margharita"; | ||
} | ||
else if (subtype === "2") { | ||
chosenSubtype = "Pepperoni"; | ||
} | ||
else if (subtype === "3") { | ||
chosenSubtype = "Hawaiian"; | ||
} | ||
else { | ||
alert("Unfortunately, we do not have that item on the menu, try again."); | ||
QuestionSubFoodType(foodType); | ||
return; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice!! |
||
} | ||
} | ||
else if (foodType === 2) { | ||
if (subtype === "1") { | ||
chosenSubtype = "Bolognese"; | ||
} | ||
else if (subtype === "2") { | ||
chosenSubtype = "Crema di pollo"; | ||
} | ||
else if (subtype === "3") { | ||
chosenSubtype = "Pesto"; | ||
} | ||
else { | ||
alert("Unfortunately, we do not have that item on the menu, try again."); | ||
QuestionSubFoodType(foodType); | ||
return; | ||
} | ||
} | ||
else if (foodType === 3) { | ||
if (subtype === "1") { | ||
chosenSubtype = "Caesar"; | ||
} | ||
else if (subtype === "2") { | ||
chosenSubtype = "Greek"; | ||
} | ||
else if (subtype === "3") { | ||
chosenSubtype = "Mozzarella"; | ||
} | ||
else { | ||
alert("Unfortunately, we do not have that item on the menu, try again."); | ||
QuestionSubFoodType(foodType); | ||
return; | ||
} | ||
} | ||
|
||
alert("You have chosen " + chosenSubtype + ". Thank you, " + userName + "!"); | ||
} | ||
|
||
// Step 2 - Food choice | ||
// Your code goes here | ||
//Now I have gotten to a point of where the client has made fully their order - final alert with the suborder and name | ||
//Step 4 - now asking the client's age | ||
|
||
// Step 3 - Subtype choice | ||
// Your code goes here | ||
let age = parseInt(prompt("Can you also tell us your age in numbers, so we know whether we can prepare the order for an adult or a child?")); | ||
|
||
// Step 4 - Age | ||
// Your code goes here | ||
if (age <= 18) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nicely done!! I used a "child" or "adult" in strings but this is a cleaner way. |
||
confirmation = prompt("Thank you for the info! One child-size, " + foodTypeName + " " + chosenSubtype + " coming right up. That'll be €10. Are you sure you want to order this? \nPlease confirm: \nyes \nno"); | ||
} else { | ||
confirmation = prompt("Thank you for the info! One adult-size, " + foodTypeName + " " + chosenSubtype + " coming right up. That'll be €15. Are you sure you want to order this? \nPlease confirm: \nYes \nNo"); | ||
} | ||
|
||
// Step 5 - Order confirmation | ||
// Your code goes here | ||
//Step 5 - the last stretch with the confirmation code | ||
if (confirmation.toLowerCase() === "yes") { | ||
alert("Thank you for your order, my friend! That will take around 10 minutes."); | ||
} else if (confirmation.toLowerCase() === "no") { | ||
alert("Alrighty! See you next time!"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice ⭐