14. 18pts Grading Criteria you should consider for the test + 4 Has the same classes as candidate objects +2 Rectangles around each class +4 Each class has at least one operation +4 Almost every class has at least one or more attributes (one is enough) +2 Reasonable associations (lines where a solid line is a dependency, dotting not required) exist +2 Has two or more reasonable multiplicity adornments (1 or * usually are possible) One Answer others are possible (a few word processor additions were made to get 100% on this question) 15. Completely implement the hierarchy here: Shape, Circle, and Rectangle public abstract class Shape { // All shapes have an upper left corner initialized by this constructor private Point p; Shape(int x, int y) { p = new Point(x, y); } // All shapes can find the x and y location public int getX() { return p.getX(); } public int getY() { return p.getY(); } // Shapes compute their area in different ways. Let the sublclasses implement getArea abstract double getArea(); } public class Rectangle extends Shape { private double my_width; private double my_height; public Rectangle(int x, int y, double height, double width) { super(x, y); my_width = width; my_height = height; } public double getArea() { return my_width * my_height; } } public class Circle extends Shape { private double my_radius; public Circle(int x, int y, double diameter) { super(x, y); my_radius = diameter / 2; } public double getArea() { return Math.PI * Math.pow(my_radius, 2); } } public interface Command { 16a)
14. 18pts Grading Criteria you should consider for the test + 4 Has the same classes as candidate objects +2 Rectangles around each class +4 Each class has at least one operation +4 Almost every class has at least one or more attributes (one is enough) +2 Reasonable associations (lines where a solid line is a dependency, dotting not required) exist +2 Has two or more reasonable multiplicity adornments (1 or * usually are possible) One Answer others are possible (a few word processor additions were made to get 100% on this question) 15. Completely implement the hierarchy here: Shape, Circle, and Rectangle public abstract class Shape { // All shapes have an upper left corner initialized by this constructor private Point p; Shape(int x, int y) { p = new Point(x, y); } // All shapes can find the x and y location public int getX() { return p.getX(); } public int getY() { return p.getY(); } // Shapes compute their area in different ways. Let the sublclasses implement getArea abstract double getArea(); } public class Rectangle extends Shape { private double my_width; private double my_height; public Rectangle(int x, int y, double height, double width) { super(x, y); my_width = width; my_height = height; } public double getArea() { return my_width * my_height; } } public class Circle extends Shape { private double my_radius; public Circle(int x, int y, double diameter) { super(x, y); my_radius = diameter / 2; } public double getArea() { return Math.PI * Math.pow(my_radius, 2); } } 16a) public interface Command {
335PracticeTest1Answers.docx