UML[ 02 ] Code with Abstract and Interface

UML[ 02 ] Code with Abstract and Interface 1

public abstract class Animal {
	public String kingdom;
	public Animal(String kingdom)
	{
		this.kingdom=kingdom;
	}
	public abstract void display();

}

public class Dinosaur extends Animal implements Habits {

	Home home;
	public int age;
	public String size;
	
	public Dinosaur(String kingdom, Home home, int age, String size) {
		super(kingdom);
		this.home = home;
		this.age = age;
		this.size = size;
	}
	public void display() {
		System.out.println("Kingdom:"+kingdom);
		home.display();
		System.out.println("Age:"+age+"\tSize:"+size);
	}
	
	
		public void running() {
			System.out.println("Running dinosaur!");
			
		}
		
		public void eating() {
			System.out.println("Eating dinosaur!");
			
		}
	public static void main(String[] args) {
		Home h1 = new Home("Nature's Art Village");
		Dinosaur d1=new Dinosaur("Animal",h1,12,"2-3 feet");
		d1.display();
		d1.running();
		d1.eating();

	}
	

}
public interface Habits {
	public void running();
	public void eating();

}

public class Home {

	public String placeOfStay;

	public Home(String placeOfStay) {
		
		this.placeOfStay = placeOfStay;
	}
	public void display()
	{
		System.out.println("Place of stay:"+placeOfStay);
	}
	
}
UML[ 02 ] Code with Abstract and Interface 2
Output
Posted in Java Programming, OOP, UML Diagram