Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This assignment will allow you to review defining Java classes and the use of an ArrayList. You are to write a set of supporting classes
This assignment will allow you to review defining Java classes and the use of an ArrayList. You are to write a set of supporting classes for a simple shopping program. We are providing GUI code (Graphical User Interface) that will provide the "front end" to the program. You are to write the back end (what is often referred to as the "domain specific code"). Below is a screen shot of what the program could look like when the user has selected various items to order. #CSE190L Gift Catalog order total $491.20 2 silly putty, $3.95 (10 for $19.99) silly string, $3.50 (10 for $14.95) 3 bottle o bubbles, $0.99 Nintendo Wii system, $389.99 Mario Computer Science Party 2 (Wii), $49.99 Don Knuth Code Jam Challenge (Wii), $49.99 Computer Science pen, $3.40 + Rubik's cube, $9.10 4 Computer Science Barbie, $19.99 12 "Java Rules!' button, $0.99 (10 for $5.00) Java Rules!' bumper sticker, $0.99 (20 for $8.95) qualify for discount Prices are expressed using doubles and quantities are expressed as simple integers (e.g., you can't buy 2.345 of something). Notice that some of the items have a discount when you buy more. For example, silly putty normally costs $3.95 each, but you can buy 10 for $19.99. These items have, in effect, two prices: a single item price and a bulk item price for a bulk quantity. When computing the price for such an item, apply as many of the bulk quantity as you can and then use the single item price for any leftovers. For example, the user is ordering 12 buttons that cost $0.99 each but can be bought in bulk 10 for $5.00. The first 10 are sold at that bulk price ($5.00) and the two extras are charged at the single item price ($0.99 each) for a total of $6.98. At the bottom of the frame you will find a checkbox for an overall discount. If this box is checked, the user is given a 10% discount off the total price. This is computed using simple12 buttons that cost $0.99 each but can be bought in bulk 10 for $5.00. The first 10 are sold at that bulk price ($5.00) and the two extras are charged at the single item price ($0.99 each) for a total of $6.98. At the bottom of the frame you will find a checkbox for an overall discount. If this box is checked, the user is given a 10% discount off the total price. This is computed using simple double arithmetic, computing a price that is 90% of what it would be otherwise. For example, if we turn on that checkbox, the frame looks like this: CSE190L Gift Catalog order total $442.08 2 silly putty, $3.95 (10 for $19.99) silly string, $3.50 (10 for $14.95) 3 bottle o bubbles, $0.99 O 1 Nintendo Wii system, $389.99 O Mario Computer Science Party 2 (Wii), $49.99 Don Knuth Code Jam Challenge (Wil), $49.99 Computer Science pen, $3.40 + Rubik's cube, $9.10 4 Computer Science Barbie, $19.99 12 "Java Rules!" button, $0.99 (10 for $5.00) "Java Rules!" bumper sticker, $0.99 (20 for $8.95) qualify for discount You are to implement four classes that are used to make this code work. You should implement a class called Item that will store information about the individual items. It should have the following public methods. Method Description Constructor that takes a name and a price as arguments. The name will be a Item(name, price) String and the price will be a double. Should throw an IllegalArgumentException is price is negative. 503You are to implement four classes that are used to make this code work. You should implement a class called Item that will store information about the individual items. It should have bottle 9 bubbles, 59.99 g Nintenue Vim system, $399.99 ! Mario Computer Science Party 2 NW), $49.99 ! Don Knuth Code Jam Ch lye (Wii), $49.99 ! Computer Science pen, $3.40 ! Rubik's cube, 39.19 g Computer Science Barbie, $19.99 new: Rules!' Ilullon. 993911991: $5.99) ! 'Java Rule P bumper slicker, $9.99 (29 for $8.95) 21 q for discount the following public methods. Method Description Constructor that takes a name and a price as arguments. The name will be a String and the price will be a double. Should throw an Item(name, price) Item(name. price. bulk quantity, bulk price) IllegalArgumentException is price is negative. Constructor that takes a name and a singleitem price and a bulk quantity and a bulk price as arguments. The name will be a String and the quantity will be an integer and the prices will be doubles. Should throw an IllegalArgumentException if any number is negative. priceFor(quantity) Returns the price for a given quantity of the item (taking into account bulk price, if applicable). Quantity will be an integer. Should throw an IllegalArgumentException if quantity is negative. toStringO Returns a String representation of this item: name followed by a comma and space followed by price. If this has a bulk price, then you should append an extra space and a parenthesized description of the bulk pricing that has the bulk quantity, the word \"for\" and the bulk price. lt #9113
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