[ Is a ] Relationship (Inheritance) | Java UML source Code

Table of Contents

[ Is a ] Relationship (Inheritance) | Java UML source Code 1
UML Diagram

Shape

package Inheritance;

public class Shape {
	
	protected int location;
	
	public Shape(int location) {
		this.location = location;
		
	}
	
	public void display() {
		System.out.println("\n" + "Location: " + location);
	}

}

Rectangle

package Inheritance;

public class Rectangle1 extends Shape{
	
	private int height, width;
	public Rectangle1(int location, int height, int width) {
		super(location);
		this.height = height;
		this.width = width;
		
	}
	
	public void display() {
		super.display();
		System.out.println("\n" + "Height:" + height + "\nWidth: "+ width);
		
	}
	
	
	public static void main(String[] args) {
		Rectangle1 r1 = new Rectangle1(5, 10, 20);
		r1.display();
	}
	
	
}

Output

[ Is a ] Relationship (Inheritance) | Java UML source Code 2