// Lecture13 -- encapsulation /* assume s1 +----+ s2 | | s4 | | +----+ s3 */ class Quad { __________ String type; __________ double s1; __________ double s2; __________ double s3; __________ double s4; __________ Quad(String t, double a, double b, double c, double d) { _________ = _________ ; _________ = _________ ; _________ = _________ ; _________ = _________ ; _________ = _________ ; } ___________________ double getArea() { double area; if (type.equals("Rect")) area = _________ ; else if (type.equals("Squa")) area = _________ ; else if (type.equals("Trap")) area = _________ ; else area = -1; return __________ ; } ___________________ _________ rect() { return _____________ ; } ___________________ _________ squa() { return _____________ ; } ___________________ _________ trap() { return ___________________________ ; } } // class Quad public class L13_area_blanks { public static void disp(String s) { System.out.println(s); } public static void main(String[] args) { // yes, the following is inefficient // investigate inheritance to "clean it up" Quad a = new Quad("Squa",1,1,1,1); Quad b = new Quad("Rect",1,2,1,2); Quad c = new Quad("Trap",2,1,3,1); disp("Area of square: " + _______________ ); disp("Area of rect: " + _______________ ); disp("Area of trap: " + _______________ ); } } // class encaps /* output: Area of square: ________ Area of rect: ________ Area of trap: ________ */