0% found this document useful (0 votes)
15 views3 pages

Package

Uploaded by

Vatsal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views3 pages

Package

Uploaded by

Vatsal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

package com.

cafe;

interface CoffeeOrder

void selectCoffee(String coffeeType);

void selectSize(String size);

void displayOrder();

double getPrice();

class CafeOrder implements CoffeeOrder

private String type;

private double basePrice;

private String size;

public void selectCoffee(String coffeeType)

if(type.equals("espresso"))

this.basePrice = 3;

else if(type.equals("latte"))

this.basePrice = 4;

else if(type.equals("mocha"))

this.basePrice = 5;

}
else{

System.out.println("not valid coffee type");

public void selectSize(String size)

if(size.equals("large"))

basePrice += 2;

else if(size.equals("medium"))

basePrice += 1;

else{

basePrice += 0;

public double getPrice()

return basePrice;

public void displayOrder()

System.out.println("coffee type " + type);

System.out.println("coffee size " + size);

System.out.println("total price " + getPrice());


}

You might also like