Question
Package Name: DessertShop Interface Names: Packaging Class Names: DessertItem Candy Cookie IceCream Sundae Suppose you want to add functionality to your Dessert Shopapplication to identify
- Package Name: DessertShop
- Interface Names:
- Packaging
- Class Names:
- DessertItem
- Candy
- Cookie
- IceCream
- Sundae
Suppose you want to add functionality to your Dessert Shopapplication to identify what type of packaging a dessert itemshould be placed in. These packaging types will show up onthe receipt. Each item will show what type of packaging itwill be place in. All items of a similar type will use thesame type of packaging.
To do this, you will add an interface to your Dessert Shopapplication and update your receipt output as described below:
Packaging Interface:
- Create an interface called Packaging
- Packaging will include two methods:
- getPackaging() which takes no arguments and returns aString
- setPackaging(String) which takes a single String argument andreturns void
DessertItem class will be updated as follows:
- DessertItem will implement Packaging
- Include an additional attribute, packaging, of typeString
- Include simple methods for getPackaging() andsetPackaging(String)
- No changes to either constructor
All subclasses (Candy, Cookie, IceCream, Sundae) will be updatedas follows:
- Call the setPackaging(String) defined in the superclass fromwithin the subclass constructors.
- For the default constructor, pass "".
- For the full argument constructors, pass the following Stringsas arguments:
- for Candy: packaging = "Bag"
- for Cookie: packaging = "Box"
- for Ice Cream: packaging = "Bowl"
- for Sundae: packaging = "Boat"
- Update the toString() method to include the packaging type in"( )" on the receipt as shown in the Example Run
Create New Test Cases:
Add JUnit test cases to your existing JUnit test classes for thefollowing new methods:
DessertItem:
- getPackaging()
- setPackaging(String)
The new interface, Packaging, has been added to your program
JUnit test cases for Candy, Cookie, Ice Cream and Sundae havebeen updated to include the new interface methods
The receipt output has been updated as shown in the ExampleRun
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