UML[ 03 ] Code with Abstract and Interface

Table of Contents

UML[ 03 ] Code with Abstract and Interface 1

public abstract class Food {
	public String color;
	public Food(String color)
	{
		this.color=color;
		
	}
	public abstract void display();

}

public class Ingredients {

	private int noOfIngredients;
	public Ingredients(int noOfIngredients)
	{
		this.noOfIngredients=noOfIngredients;
	}
	public void display()
	{
		System.out.println("No OF Ingredients: "+noOfIngredients);
	}
}

public class Kacchi extends Food implements Price {
	Ingredients ing;
	public String typeOfKacchi,sizeOfPlate;
	
	

	
	public Kacchi(String color, Ingredients ing, String typeOfKacchi, String sizeOfPlate) {
		super(color);
		this.ing = ing;
		this.typeOfKacchi = typeOfKacchi;
		this.sizeOfPlate = sizeOfPlate;
	}
	public void display()
	{
		System.out.println("Color:"+color);
		ing.display();
		System.out.println("Type Of Kacchi:"+typeOfKacchi);
		System.out.println("Size Of Plate:"+sizeOfPlate);
	}


	public void highPrice() {
		System.out.println("High Price !");

	}

	
	public void lowPrice() {
		System.out.println("Low Price !");

	}
	public static void main(String[] args) {
		Ingredients i =new Ingredients(5);
		Kacchi k = new Kacchi("White",i,"Sindhi Biryani","Medium");
		k.display();
		k.highPrice();
		k.lowPrice();
		
	}

}

public interface Price {

	public void highPrice();
	public void lowPrice();
}
UML[ 03 ] Code with Abstract and Interface 2
Output