<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">// Lecture19 -- 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 encaps {

    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 square: " + _______________ );

	disp("Area of square: " + _______________ );

    }

} // class encaps

/* output:
Area of square: ________

Area of square: ________

Area of square: ________
*/
</pre></body></html>