This is a webpage that allows the user to create a pizza order (pizza size and toppings) and see how much it will cost based on their selections.
- I structured the application data with JavaScript objects created with constructor functions.
- I added functionality to Pizza objects by creating getBasePrice, getToppingsPrice, and calculatePrice methods to the object's prototype.
- To ensure that the application is efficient and effective, I implemented the 'separation of concerns' principle to create JavaScript functions that focus on doing just one thing.
- Additionally, I used event delegation to attach an event listener to a parent element that fires for a child element, which enhances the application's functionality and user experience.
amandaguan-ag.github.io/pizza/
- HTML
- CSS
- bootstrap
- Javascript
- Clone this repository to your desktop
- Navigate to the top level of the directory
- Open index.html
- No known bugs
Copyright (c) 2023, Amanda GUan
Amanda Guan ag.amandaguan@gmail.com
Test: "It should return a Pizza object with three properties for buyer name, size and toppings"
Code: const pizza = new Pizza("Bob", "medium", 3);
Expected Output: Pizza { customerName: "Bob", pizzaSize: "medium", orderToppings: 3 }
Test 1: "It should return base price for extra-large pizza"
Code: const pizza = new Pizza("Bob", "extra-large", 3); const result = pizza.getBasePrice();
Expected Output:10
Test 2: "It should return base price for large pizza"
Code: const pizza = new Pizza("Bob", "large", 3); const result = pizza.getBasePrice();
Expected Output:8
Test 3: "It should return base price for medium pizza"
Code: const pizza = new Pizza("Bob", "medium", 3); const result = pizza.getBasePrice();
Expected Output:6
Test 4: "It should return base price for small pizza"
Code: const pizza = new Pizza("Bob", "small", 3); const result = pizza.getBasePrice();
Expected Output:4
Test 1: "It should return toppings price for 4 toppings"
Code: const pizza = new Pizza("Bob", "medium", 4); const result = pizza.getToppingsPrice();
Expected Output:4
Test 2: "It should return toppings price for 3 toppings"
Code: const pizza = new Pizza("Bob", "medium", 3); const result = pizza.getToppingsPrice();
Expected Output:3
Test 3: "It should return toppings price for 2 toppings"
Code: const pizza = new Pizza("Bob", "medium", 2); const result = pizza.getToppingsPrice();
Expected Output:2
Test 4: "It should return toppings price for 1 toppings"
Code: const pizza = new Pizza("Bob", "medium", 1); const result = pizza.getToppingsPrice();
Expected Output:1
Test 5: "It should return toppings price for 0 toppings"
Code: const pizza = new Pizza("Bob", "medium", 0); const result = pizza.getToppingsPrice();
Expected Output:0
Test: "It should calculate the total price of a pizza"
Code: const pizza = new Pizza("Bob", "medium", 4); const result = pizza.calculatePrice();
Expected Output:10