Answered step by step
Verified Expert Solution
Question
1 Approved Answer
public class Polygon { /* Attributes */ private Point[] vertices = new Point[size]; // list of vertices in order /* Constructors */ public Polygono /*
public class Polygon { /* Attributes */ private Point[] vertices = new Point[size]; // list of vertices in order /* Constructors */ public Polygono /* Getters and Setters */ public Point[getVertices() { return vertices; 3 public void setVertices(Point[] vertices) { this.vertices = vertices; } /* Other methods */ public double area { System.out.println("I won't compute it at this level. Please run it at the subclass level"); return -1; } public class Rectangle extends Polygon { /* Constructors */ public Rectangle() { super(); } public double area() { Point[] vertices = getVertices(); double side1 = Math.sqrt(Math.pow(vertices[0].getX(-vertices[1].getX(), 2) + Math.pow(vertices[0].getYO-vertices[1].getYO, 2)); double side2 = Math.sqrt(Math.pow(vertices[2].getX(-vertices[1].getX(), 2) + Math.pow(vertices[2].getY(-vertices[1].getYO, 2)); return side1 * side2; } What do you observe in this code among the following? Encapsulation Overloading Overriding For each property you observed, explain where in the code you observed it and what it means
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started