Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Computer Performance Engineering 10th European Workshop Epew 2013 Venice Italy September 17 2013 Proceedings

Authors: Maria Simonetta Balsamo ,William Knottenbelt ,Andrea Marin

2013 Edition

3642407242, 978-3642407246

More Books

Students also viewed these Programming questions

Question

17. Describe the major controls for cash payments.

Answered: 1 week ago

Question

Problem 1-32 Problem 1-30 Excersise 1.4

Answered: 1 week ago