Question
Using C# language.... This is a simple assignment on advanced exception handling. Create a PizzaOrder class or look into your files from the first class
Using C# language....
This is a simple assignment on advanced exception handling.
Create a PizzaOrder class or look into your files from the first class and copy it out. It should have the following properties (and their underlying private variables): Size {of type int}, Toppings {of type String}, Price {of type Decimal}. Make a full constructor for the class that takes all three values, and a default constructor that initializes the basic pizza as a 12 inch cheese pizza for $8. Make sure to include validation in your Size and Price properties and constructor to prevent a change to Size that would be less than 12 or greater than 16, and prevent a change to Price that would be less than 0.
The PizzaOrder class should be changed to throw exceptions in the Sets for invalids sizes and invalid prices. Include exception handing in your program to test for invalid prices and sizes, do not include Try/Catches in the Sets, or the constructor, of any part of the PizzaOrder class. This class should only throw exceptions not handle them.
In the main program create an Array of 4 PizzaOrders. Go ahead and create the 4 PizzaOrders in the array.
Write an indefinite loop that allows a user to enter in changes for a PizzaOrder, including the number of the PizzaOrder to change. Include a Try/Catch inside the loop that catches the exceptions thrown in bad values being used to change the current object ( and gives a message to the user instead of changing it.) It should display the 4 pizzas showing their current values as the last thing in the loop.
The Try/Catch inside the loop in main() should have a catch any exception thrown by the PizzaOrder class, as well as an exception to catch format types (when the user enters a value that will go into a number field and it cannot be converted into a number from the value they put in), and a catch to handle the user giving a number to use as the index which is off the array. .there should be multiple catches in this one Try/Catch to handle the different exceptions and give appropriate messages.
This program will be tested with valid changes, an invalid size, an invalid negative price, the word Five for a price or size, and a position number not in the array. It shouldnt crash on any invalid test.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started