diff --git a/README.md b/README.md index 33c7e601..652e298d 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,10 @@ # 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. +The assignment for this week was to create a Javascript pizzeria based on user inputs using methods like prompt and alert. ## The problem +During this week I approached many problems and it was hard to keep my head straight at times. I ended up trying stuff out and then deleting the code a few times to start over. I also got some help from a friend who's a programmer and he introduced me to functions in javascript. Afterwards I somehow ended up even more confused so I started over again and skipped using functions. Instead I used google, chatgpt and stack overflow to help me move forward. I also used the javascript pizzeria example on disco and took a lot of inspiration from that. Before I started coding I went to the example and tried to identify the different steps in the requirments and match them with the stages in the pizzeria example. -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? +If I had more time I would add while loops to my code to make sure the user has to choose an option before they leave for the next step or the page. In my code now the user has to refresh the page and start over if they would like to change something or picked the wrong option etc. ## 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://elinasjavascriptpizzeria.netlify.app/ \ No newline at end of file diff --git a/code/script.js b/code/script.js index 34ca0f34..84ff06f3 100644 --- a/code/script.js +++ b/code/script.js @@ -1,19 +1,104 @@ -// Start here - // Step 1 - Welcome and introduction -// Your code goes here alert( - `Welcome to our Javascript Pizzeria. Ready to Start? - Click 'OK' to begin.` + "Welcome to our Javascript Pizzeria. Ready to Start? - Click 'OK' to begin." ) +let userName = prompt("Please enter your name:"); + +alert(`Hi, ${userName}!`) + // Step 2 - Food choice -// Your code goes here +let foodChoice = prompt("What type of food would you like to order?\nEnter a number:\n1 - Pizza\n2 - Pasta\n3 - Salad"); + +// User food coice +let foodName = ""; +if (foodChoice === "1") { + foodName = "Pizza"; + alert("You have selected Pizza!"); +} else if (foodChoice === "2") { + foodName = "Pasta"; + alert("You've selected Pasta"); +} else if (foodChoice === "3") { + foodName = "Salad"; + alert("You've selected Salad"); +} else { + alert("Invalid choice, please enter a number between 1 and 3."); +} + +//Step 3 Subtype choice +let subTypeChoice = ""; +let subTypeName = ""; + +if (foodChoice === "1") { + // subtypes for pizza + subTypeChoice = prompt("Which type of Pizza would you like?\n1 - Margherita\n2 - Pepperoni\n3 - Vesuvio"); + if (subTypeChoice === "1") { + subTypeName = "Margherita"; + alert("You've selected Margherita!"); + } else if (subTypeChoice === "2") { + subTypeName = "Pepperoni"; + alert("You've selected Pepperoni!"); + } else if (subTypeChoice === "3") { + subTypeName = "Vesuvio"; + alert("You've selected Vesuvio!"); + } else { + alert("Invalid choice, please enter a number between 1 and 3."); + } +} else if (foodChoice === "2") { + // subtypes for pasta + subTypeChoice = prompt("Which type of Pasta would you like?\n1 - Spaghetti Carbonara!\n2 - Lasagna!\n3 - Cheesy Tortellini!"); + if (subTypeChoice === "1") { + subTypeName = "Spaghetti Carbonara"; + alert("You've selected Spaghetti Carbonara!"); + } else if (subTypeChoice === "2") { + subTypeName = "Lasagna"; + alert("You've selected Lasagna!"); + } else if (subTypeChoice === "3") { + subTypeName = "Cheesy Tortellini"; + alert("You've selected Cheesy Tortellini!"); + } else { + alert("Invalid choice, please enter a number between 1 and 3."); + } +} else if (foodChoice === "3") { + //subtypes for salad + subTypeChoice = prompt("Which type of salad would you like?\n1 - Ceasar Salad!\n2 - Greek Salad!\n3 - Garden Salad!"); + if (subTypeChoice === "1") { + subTypeName = "Ceasar Salad"; + alert("You've selected Ceasar Salad!"); + } else if (subTypeChoice === "2") { + subTypeName = "Greek Salad"; + alert("You've selected Greek Salad!"); + } else if (subTypeChoice === "3") { + subTypeName = "Garden Salad"; + alert("You've selected Garden Salad!"); + } else { + alert("Invalid choice, please enter a number between 1 and 3."); + } +} + +// Step 4 - Identify user's age +let userAge = prompt("Please enter your age:"); + +//variable to store the size and price based on age +let size = ""; +let price = ""; -// Step 3 - Subtype choice -// Your code goes here +// check if user is a child or an adult +if (userAge >= 18) { + size = "adult"; + price = 15; +} else if (userAge > 0 && userAge < 18) { + size = "child"; + price = 10; +} else { + alert("Invalid input, please enter a valid age"); +} -// Step 4 - Age -// Your code goes here +let confirmation = prompt(`One ${size} sized ${subTypeName} will be prepared for you. That'll be €${price}. Are you sure you want to order this?\nEnter a number to confirm:\n1 - Yes\n2 - No`); // Step 5 - Order confirmation -// Your code goes here +if (confirmation === "1") { + alert("Your order has been confirmed. Enjoy your meal!"); +} else { + alert("Your order has been cancelled. Feel free to order our delicious food in the future!"); +} \ No newline at end of file diff --git a/code/style.css b/code/style.css index d384d122..404c659d 100644 --- a/code/style.css +++ b/code/style.css @@ -17,4 +17,4 @@ body { p { font-size: 1.5em; -} +} \ No newline at end of file diff --git a/pull_request_template.md b/pull_request_template.md index e239e19f..9052d0b3 100644 --- a/pull_request_template.md +++ b/pull_request_template.md @@ -1,6 +1,2 @@ ## 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. +https://elinasjavascriptpizzeria.netlify.app/