Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package restaurant;
- import java.math.BigDecimal;
- public class Beverage extends Product {
- private double milliliters;
- public Beverage(String name, BigDecimal price, double milliliters) {
- super(name, price);
- this.milliliters=milliliters;
- }
- public double getMilliliters() {
- return milliliters;
- }
- }
- //=======================================================================================================
- package restaurant;
- import java.math.BigDecimal;
- public class ColdBeverage extends Beverage{
- public ColdBeverage(String name, BigDecimal price, double milliliters) {
- super(name, price, milliliters);
- }
- }
- //=======================================================================================================
- package restaurant;
- import java.math.BigDecimal;
- public class HotBeverage extends Beverage{
- public HotBeverage(String name, BigDecimal price, double milliliters) {
- super(name, price, milliliters);
- }
- }
- //=======================================================================================================
- package restaurant;
- import java.math.BigDecimal;
- public class Coffee extends HotBeverage {
- private static final double COFFEE_MILLILITERS = 50.0;
- private static final BigDecimal COFFEE_PRICE = BigDecimal.valueOf(3.50);
- private double caffeine;
- public Coffee(String name, BigDecimal price, double milliliters) {
- super(name, price, milliliters);
- }
- public double getCaffeine() {
- return caffeine;
- }
- }
- //=======================================================================================================
- package restaurant;
- import java.math.BigDecimal;
- public class Tea extends HotBeverage {
- public Tea(String name, BigDecimal price, double milliliters) {
- super(name, price, milliliters);
- }
- }
- //=======================================================================================================
- package restaurant;
- import java.math.BigDecimal;
- public class Food extends Product{
- private double grams;
- public Food(String name, BigDecimal price, double grams) {
- super(name, price);
- this.grams = grams;
- }
- public double getGrams() {
- return grams;
- }
- }
- //=======================================================================================================
- package restaurant;
- import java.math.BigDecimal;
- public class MainDish extends Food {
- public MainDish(String name, BigDecimal price, double grams) {
- super(name, price, grams);
- }
- }
- //=======================================================================================================
- package restaurant;
- import java.math.BigDecimal;
- public class Starter extends Food{
- public Starter(String name, BigDecimal price, double grams) {
- super(name, price, grams);
- }
- }
- //=======================================================================================================
- package restaurant;
- import java.math.BigDecimal;
- public class Dessert extends Food{
- private double calories;
- public Dessert(String name, BigDecimal price, double grams, double calories) {
- super(name, price, grams);
- this.calories = calories;
- }
- public double getCalories() {
- return calories;
- }
- }
- //=======================================================================================================
- package restaurant;
- import java.math.BigDecimal;
- public class Soup extends Starter {
- public Soup(String name, BigDecimal price, double grams) {
- super(name, price, grams);
- }
- }
- //=======================================================================================================
- package restaurant;
- import java.math.BigDecimal;
- public class Dessert extends Food{
- private double calories;
- public Dessert(String name, BigDecimal price, double grams, double calories) {
- super(name, price, grams);
- this.calories = calories;
- }
- public double getCalories() {
- return calories;
- }
- }
- //=======================================================================================================
- package restaurant;
- import java.math.BigDecimal;
- public class Salmon extends MainDish {
- private final static double SALMON_GRAMS = 22.0;
- public Salmon(String name, BigDecimal price, double grams) {
- super(name, price, grams);
- }
- }
- //=======================================================================================================
- package restaurant;
- import java.math.BigDecimal;
- public class Product {
- private String name;
- private BigDecimal price;
- public Product(String name, BigDecimal price) {
- this.setName(name);
- this.setPrice(price);
- }
- private void setPrice(BigDecimal price) {
- if (this.price ==null){
- this.price = price;
- }
- }
- private void setName(String name) {
- if (this.name == null){
- this.name = name;
- }
- }
- public String getName() {
- return name;
- }
- public BigDecimal getPrice() {
- return price;
- }
- }
Add Comment
Please, Sign In to add comment