Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question 3 T-Shirts 4U is a company that sells bulk t-shirts of different sizes (Large, Medium and Small). Write a Python class definition called Order
Question 3 T-Shirts 4U is a company that sells bulk t-shirts of different sizes (Large, Medium and Small). Write a Python class definition called Order which keeps track of each order placed with the company for t-shirts and computes the total cost of each order which includes a 15% sales tax on the discounted total cost, if a discount can be applied. In addition, the class definition should also keep track of the total number of small, medium and large t-shirts from all orders placed. Assume that a discount of 10% is given if more than 100 t-shirts are ordered in a single order. For each order the following information is maintained: a class variable representing the last order ID used, starting at 100 an order ID, which is 101 for the first order, 102 for the second order, etc (hint: use the class variable) the number of large t-shirts ordered, with default value of 0 the number of medium t-shirts ordered, with default value of 0 the number of small t-shirts ordered, with default value of 0 class variables for the total large, medium and small shirts ordered so far from all orders e Include the following methods in the class definition: a constructor to initialize all instance variables and update class variables; include appropriate default values for parameters an accessor method to get the order ID, number of large, medium and small t-shirts ordered, and to compute and return the total t-shirts ordered for that single order a mutator method to update the number of t-shirts of any size ordered, given the size of t-shirt ("L" for large, "M" for medium or "S" for small) and the number of extra t-shirts of that size to be added to the late W Into the annronriate total as well a mutator method to update the number of t-shirts of any size ordered, given the size of t-shirt ("L" for large, "M" for medium or "S" for small) and the number of extra t-shirts of that size to be added to the existing order; be sure to update the appropriate total as well a method to compute the basic cost of the order (ignoring discount and taxes); the cost of each t-shirt based on size is: Small - $5, Medium - $8, Large - $10 a method to compute the discount for an order of more than 100 t-shirts; 10% off of the basic cost, or zero if the order is for 100 or less t-shirts a method to compute the tax, after any discount has been removed from the basic cost a method to compute the total cost of the order, i.e., the basic cost, less any discount, plus taxes a special method str to return a string containing information about the order (order ID, number of large, medium and small t-shirts, basic order cost, discount amount, taxes and the total cost of the order) O Test your class by coding a main() function to: create 4 Order objects print required information about each object (using the str method) update the order of small t-shirts by some amount for one of the orders print the total number of all the t-shirts sold over all orders O Sample input/output: With the following sample input for 4 orders: Irg = 20, med = 40, sml = 60 Irg = 15, med = 20 Irg = 40 Irg = 0, med = 0, sml = 45 And an update on the order with ID 103 for an extra 50 small shirts. The following is the output: OrderID: 101 Num Large T-Shirts: 20 Num Medium T-Shirts: 40 Num Small T-Shirts: 60 Basic Order Cost: $820.00 Discount: $82.00 Tax: $110.70 Total Cost of the Order: $848.70 OrderID: 102 Num Large T-Shirts: 15 Num Medium T-Shirts: 20 OrderID: 102 Num Large T-Shirts: 15 Num Medium T-Shirts: 20 Num Small T-Shirts: 0 Basic Order Cost: $310.00 Discount: $0.00 Tax: $46.50 Total Cost of the Order: $356.50 Order ID: 103 Num Large T-Shirts: 40 Num Medium T-Shirts: 0 Num Small T-Shirts: 0 Basic Order Cost: $400.00 Discount: $0.00 Tax: $60.00 Total Cost of the Order: $460.00 OrderID: 104 Num Large T-Shirts: 0 Num Medium T-Shirts: 0 Num Small T-Shirts: 45 Basic Order Cost: $225.00 Discount: $0.00 Tax: $33.75 Total Cost of the Orden: $258075 Discount: $0.00 Tax: $33.75 Total Cost of the Order: $258.75 Updated Order for 103: OrderID: 103 Num Large T-Shirts: 40 Num Medium T-Shirts: 0 Num Small T-Shirts: 50 Basic Order Cost: $650.00 Discount: $0.00 Tax: $97.50 Total cost of the Order: $747.50 The total number of t-shirts sold is: 290 Call the file containing your class and main function shirtorders.py: Question 3 T-Shirts 4U is a company that sells bulk t-shirts of different sizes (Large, Medium and Small). Write a Python class definition called Order which keeps track of each order placed with the company for t-shirts and computes the total cost of each order which includes a 15% sales tax on the discounted total cost, if a discount can be applied. In addition, the class definition should also keep track of the total number of small, medium and large t-shirts from all orders placed. Assume that a discount of 10% is given if more than 100 t-shirts are ordered in a single order. For each order the following information is maintained: a class variable representing the last order ID used, starting at 100 an order ID, which is 101 for the first order, 102 for the second order, etc (hint: use the class variable) the number of large t-shirts ordered, with default value of 0 the number of medium t-shirts ordered, with default value of 0 the number of small t-shirts ordered, with default value of 0 class variables for the total large, medium and small shirts ordered so far from all orders e Include the following methods in the class definition: a constructor to initialize all instance variables and update class variables; include appropriate default values for parameters an accessor method to get the order ID, number of large, medium and small t-shirts ordered, and to compute and return the total t-shirts ordered for that single order a mutator method to update the number of t-shirts of any size ordered, given the size of t-shirt ("L" for large, "M" for medium or "S" for small) and the number of extra t-shirts of that size to be added to the late W Into the annronriate total as well a mutator method to update the number of t-shirts of any size ordered, given the size of t-shirt ("L" for large, "M" for medium or "S" for small) and the number of extra t-shirts of that size to be added to the existing order; be sure to update the appropriate total as well a method to compute the basic cost of the order (ignoring discount and taxes); the cost of each t-shirt based on size is: Small - $5, Medium - $8, Large - $10 a method to compute the discount for an order of more than 100 t-shirts; 10% off of the basic cost, or zero if the order is for 100 or less t-shirts a method to compute the tax, after any discount has been removed from the basic cost a method to compute the total cost of the order, i.e., the basic cost, less any discount, plus taxes a special method str to return a string containing information about the order (order ID, number of large, medium and small t-shirts, basic order cost, discount amount, taxes and the total cost of the order) O Test your class by coding a main() function to: create 4 Order objects print required information about each object (using the str method) update the order of small t-shirts by some amount for one of the orders print the total number of all the t-shirts sold over all orders O Sample input/output: With the following sample input for 4 orders: Irg = 20, med = 40, sml = 60 Irg = 15, med = 20 Irg = 40 Irg = 0, med = 0, sml = 45 And an update on the order with ID 103 for an extra 50 small shirts. The following is the output: OrderID: 101 Num Large T-Shirts: 20 Num Medium T-Shirts: 40 Num Small T-Shirts: 60 Basic Order Cost: $820.00 Discount: $82.00 Tax: $110.70 Total Cost of the Order: $848.70 OrderID: 102 Num Large T-Shirts: 15 Num Medium T-Shirts: 20 OrderID: 102 Num Large T-Shirts: 15 Num Medium T-Shirts: 20 Num Small T-Shirts: 0 Basic Order Cost: $310.00 Discount: $0.00 Tax: $46.50 Total Cost of the Order: $356.50 Order ID: 103 Num Large T-Shirts: 40 Num Medium T-Shirts: 0 Num Small T-Shirts: 0 Basic Order Cost: $400.00 Discount: $0.00 Tax: $60.00 Total Cost of the Order: $460.00 OrderID: 104 Num Large T-Shirts: 0 Num Medium T-Shirts: 0 Num Small T-Shirts: 45 Basic Order Cost: $225.00 Discount: $0.00 Tax: $33.75 Total Cost of the Orden: $258075 Discount: $0.00 Tax: $33.75 Total Cost of the Order: $258.75 Updated Order for 103: OrderID: 103 Num Large T-Shirts: 40 Num Medium T-Shirts: 0 Num Small T-Shirts: 50 Basic Order Cost: $650.00 Discount: $0.00 Tax: $97.50 Total cost of the Order: $747.50 The total number of t-shirts sold is: 290 Call the file containing your class and main function shirtorders.py
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