This project requires the use of the following Java program files:
|
Download them to your PC before doing this project.
Abide to the Emory Honor code when doing assignments.
The menu at a lunch counter includes a variety of sandwiches, salads, and drinks. Each menu item has a name and a price.
A menu item is represented by a MenuItem object defined in the MenuItem.java class file as follows:
/* ------------------------------------------------------------ MenuItem: this is the super class used to construct the Sandwich, Salad and Drink classes in this homework assignment ***** Do NOT make changes to this program file !!! ***** ----------------------------------------------------------- */ public class MenuItem { private String name; // Name of the menu item private double price; // Price of the menu item // Constructor public MenuItem(String n, double p) { name = n; price = p; } // getName(): returns the name of this menu item public String getName() { return name; } // getPrice(): returns the price of this menu item public double getPrice() { return price; } } |
You are to use the MenuItem class to implement 3 types menu items (i.e.: these are subclasses of MenuItem)
The three types of menu items are represented by the following 3 classes:
|
Part A of the assignment requires you to implement:
|
Use the Java program PartA.java to test your Sandwich, Salad and Drink classes.
A customer can create a "trio," which consists of three menu items: a sandwich, a salad, and a drink. The Trio class contained in Trio.java represents a "trio". The Trio class in this file is as follows:
public class Trio { private Sandwich sandwich; private Salad salad; private Drink drink; // Part B: write the getPrice() method for the Trio class public double getPrice() { // Price of a trio (combo meal) is the sum of the 2 highest priced // items in the trio // // Compute the price of a trio and return it } // Constructor public Trio(Sandwich s1, Salad s2, Drink d) { sandwich = s1; salad = s2; drink = d; } } |
The price of the "trio" is the sum of the two highest-priced menu items in the "trio"; one item with the lowest price is free.
For Part B of the assignment, write the getPrice() method in the Trio class
Use your web browser and visit the cs171 turnin website: click here
|
Follow the instructions given in homework 1 to turn in.
You must be on Emory campus (e.g.: Emory unplugged) in order to turn in an assignment
Use your web browser and visit the cs171 turnin website: click here
Use assignment code hw3 to request extension for this homework.
Follow the instructions given in homework 1 to request extension.