Question: Create the following structure in Eclipse for this lab. Package Name: DessertShop Class Names: DessertItem, Candy ,Cookie, IceCream, Sundae A Dessert Shop sells candy by
Create the following structure in Eclipse for this lab.
Package Name: DessertShop
Class Names: DessertItem, Candy ,Cookie, IceCream, Sundae
A Dessert Shop sells candy by the pound, cookies by the dozen, ice cream by the scoop, and sundaes (ice cream with a topping).
In this lab, you will create the structure for a Dessert Shop program. There will be no user interface nor input/output in conjunction with this lab. The lab will be tested using JUnit test cases.
To do this, you will implement an inheritance hierarchy of classes derived from a DessertItem superclass. Candy, Cookie, and IceCream classes will derive from the DessertItem class. The Sundae class will derive from the IceCream class. The classes will be structured as follows:
The DessertItem Superclass contains:
- A single attribute, name
- The name attribute MUST be private. You may not use the 'protected' access modifier.
- Two constructors:
- A default that takes no arguments and sets the name instance variable to a default 0-type value
- One which has one argument and sets the name instance variable to the passed in argument
- An appropriate get()-type method and a set()-type method for the name attribute
- The getter()-type method takes no arguments and returns the appropriate instance variable
- The setter()-type method takes an appropriate argument and sets the appropriate instance variable. The setter() -type methods will not return any values.
All derived subclasses (Candy, Cookie, IceCream, and Sundae) contain:
- Attributes as described below
- Two constructors:
- A default that takes no arguments calls the default constructor of the superclass and sets all instance variables local to the class to default 0-type values.
- One which has enough arguments to populate ALL instance variable (both local and those from the superclass), calls the all-argument constructor of the superclass, and sets all instance variables local to the class to the passed in arguments of the constructor.
- Appropriate get()-type methods and a set()-type methods for each instance variable local to the class
- Each getter()-type method takes no arguments and returns the appropriate instance variable
- The setter()-type method takes an appropriate argument and sets the appropriate instance variable. The setter() -type methods will not return any values.
The Candy Class:
- Contains only two attributes:
- double candyWeight
- double pricePerPound
The Cookie Class:
- Contains only two attributes:
- int cookieQty
- double pricePerDozen
The IceCream Class:
- Contains only two attributes:
- int scoopCount
- double pricePerScoop
The Sundae Class:
- Contains only two attributes:
- String toppingName
- double toppingPrice
Create JUnit test cases for each method for each class.
- The DessertItem class will have 2 test cases
- All other classes will have 4 test cases
Keep each test case simple as described below!
getter()-type methods
Test cases for all get()-type methods will:
- Invoke the all-attribute constructor
- Call the appropriate get() method
- Compare the value returned from the get() method with the value passed into the constructor.
setter()-type methods
Test cases for all set()-type methods will:
- Invoke the all-attribute constructor
- Call the appropriate set() method, changing the value passed in through the constructor
- Compare the value passed to the set() method with the value returned from the getter() method to ensure the value change from the original constructor invocation.
All classes and methods are created as described above.
All JUnit test cases are created as described above.
All JUnit test cases pass.
Turn in TEN (10) .java files:
- DessertItem.java
- DessertItemTest.java
- Candy.java
- CandyTest.java
- Cookie.java
- CookieTest.java
- IceCream.java
- IceCreamTest.java
- Sundae.java
- SundaeTest.java
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
