public class Parallelogram2 { // We keep a Rectangle object with us instead of x,y,w,h Rectangle internal_rect; double angle; Parallelogram2(double width, double height, double an){ internal_rect = new Rectangle(width, height); angle = an; } double area(){ return internal_rect.area()*Math.sin(angle); } void setPosition(double xpos, double ypos){ internal_rect.setPosition(xpos, ypos); } double getAngle(){ return angle; } void printDetails(){ System.out.println("pos = ("+internal_rect.x+", "+internal_rect.y+"), area = "+area()); } public static void main(String args[]){ Rectangle rect1; Parallelogram plg1; Parallelogram2 plg2; rect1 = new Rectangle(20, 10); plg1 = new Parallelogram(20, 10, 1); plg2 = new Parallelogram2(20, 10, 1); rect1.printDetails(); plg1.printDetails(); plg2.printDetails(); } }