Question: Java language please . In this exercise, Shape shall be defined as an abstract class, which contains: Two protected instance variables color(String) and filled(boolean). The

. In this exercise, Shape shall be defined as an abstract class, which contains: Two protected instance variables color(String) and filled(boolean). The protected variables can be accessed by its subclasses and classes in the same package. They are denoted with a '#' sign in the class diagram. Getter and setter for all the instance variables, and toStringO. Two abstract methods getArea() and getPerimeter() (shown in italics in the class diagram). . Subclasses Circle and Rectangle shall override the abstract methods getArea() and get Perimeter() and provide the proper implementation. They also override the toString(). Write a test class to test these statements involving polymorphism. Task 2: In this lab exercise you will develop a class hierarchy of shapes and write a program that computes the amount of paint needed to paint different objects. The hierarchy will consist of a parent class Shape with three derived classes - Sphere, Rectangle, and Cylinder. For the purposes of this exercise, the only attribute a shape will have is a name and the method of interest will be one that computes the area of the shape (surface area in the case of three-dimensional shapes). Do the following. 1. Write an abstract class Shape with the following properties: a. An instance variable shapeName of type String b. An abstract method area c. A toString method that returns the name of the shape 2. The file Sphere.java contains a class for a sphere which is a descendant of Shape. A sphere has a radius and its area (surface area) is given by the formula 4*PI*radius^2. Define similar classes for a rectangle and a cylinder. Both the Rectangle class and the Cylinder class are descendants of the Shape class. A rectangle is defined by its length and width and its area is length times width. A cylinder is defined by a radius and height and its area (surface area) is PI*radius 2*height. Define the toString method in a way similar to that for the Sphere class. 3. The file Paint.java contains a class for a type of paint (which has a "coverage" and a method to compute the amount of paint needed to paint a shape). Correct the return statement in the amount method so the correct amount will be returned. Use the fact that the amount of paint needed is the area of the shape divided by the coverage for the paint. (NOTE: Leave the print statement - it is there for illustration purposes, so you can see the method operating on different types of Shape object 4. 4. The file Paint Things.java contains a program that computes the amount of paint needed to paint various shapes. A paint object has been instantiated. Add the following to complete the program
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
