Lunch Special Download

Christina Cacioppo

classes, interface, constructors Student approved


Introduction

Congratulations: you've just been hired to help a deli sort out its online ordering system!

The deli has three types of menu items:

Here's the menu:

SandwichSoupDrink
Hamburger
$6.50
Potato
$1.75
Coffee
$2.00
Chicken salad
$5.50
Tomato
$3.50
Coke
$3.00

The deli's owners would like to add a lunch special to the menu, which is 1 sandwich, 1 soup, and 1 drink, for the combined price of the two highest-priced items in the set.

So a lunch special of a hamburger ($6.50), tomato soup ($4.50), and Coke ($2) would cost $11.


Task

The developer who came before you left things in good shape, and you can use some of her code. Specifically, she created a MenuItem interface with two accessor methods: getName() and getPrice().

We need to write the LunchSpecial class that groups a Sandwich, Soup, and Drink.

LunchSpecial(Sandwich mySandwich, Soup mySoup, Drink myDrink);


Starter code

public interface MenuItem{
	// @return	the name of the menu item
	String getName();

	// @return	the price of the menu item
	double getPrice();	
}
class LunchSpecial implements MenuItem{
	/*		Your code here		*/	
}

Expected output

If we made the `LunchSpecial` mentioned above, it should have the name "Hamburger/Tomato Soup/Coke" and cost $11.

// Assume chosenSandwich is a Sandwich object representing a hamburger, chosenSoup is Soup object representing tomato, and chosenDrink is a Drink object representing a Coke.
    
    LunchSpecial special = new LunchSpecial(chosenSandwich, chosenSoup, chosenDrink);
    special.getPrice();
    // returns 11.00
    special.getName();
    // returns "Hamburger/Tomato Soup/Coke"

Useful tools to solve the problem