class Pond { double radius; // meter Pond( double r ) { this.radius = r; } double getArea() { return Math.PI * this.radius * this.radius; } } class Garden { double length; // meter double width; // meter Pond pond; // include a default constructor to avoid problems Garden( ) { length = 0; width = 0; } Garden( double len, double wid ) { this.length = len; this.width = wid; } Garden( double len, double wid, double pr ) { this.length = len; this.width = wid; this.pond = new Pond( pr ); } double calcTax() { double tax = 0; if ( this.pond != null) { tax = this.pond.getArea() * 10; } tax = tax + this.width * this.length * 5; return tax; } } class MarketGarden extends Garden { String[] crops; MarketGarden(double len, double wid, String[] cr) { this.length = len; this.width = wid; this.crops = cr; } void printCrops() { for (String c : crops) { System.out.println( c ); } } // @override double calcTax() { return this.width * this.length * 4 + crops.length * 10; } } class Dorknoper { Garden g; Garden h; void doTax() { double tax1; this.g = new Garden(12, 10, 2); this.h = new MarketGarden( 20, 7, new String[]{"lettuce", "carrots"} ); tax1 = this.g.calcTax(); System.out.println("belasting tuin 1: "+ tax1); System.out.println("belasting tuin 2: "+ this.h.calcTax() ); } public static void main(String[] args) { new Dorknoper().doTax(); } }