// 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) { // I was in MATLAB mode when I wrote this. 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 square: " + _______________ ); disp("Area of square: " + _______________ ); } } // class encaps /* output: Area of square: ________ Area of square: ________ Area of square: ________ */