Question: For JAVA programming. 1. Write an inheritance hierarchy for classes of simple shapes. Create a class Shape. Derive the four classes ZeroDimensionalShape, OneDimensionalShape, TwoDimensionalShape and

 For JAVA programming. 1. Write an inheritance hierarchy for classes of
simple shapes. Create a class Shape. Derive the four classes ZeroDimensionalShape, OneDimensionalShape,
For JAVA programming.

1. Write an inheritance hierarchy for classes of simple shapes. Create a class Shape. Derive the four classes ZeroDimensionalShape, OneDimensionalShape, TwoDimensionalShape and ThreeDimensionalShape from the Shape class. Derive the classes Point, Line, Circle, and Sphere from these four classes. Use abstract classes to define Shape, OneDimensionalShape, TwoDimensionalShape and ThreeDimensionalShape classes, and then implement them in the Line, Circle and Sphere classes. (See book pg 510 for information about abstract classes and methods.) Include a shapelD variable in the Shape class and a getID method to get the ID for each shape created. Create a unique ID for each instance of a Shape. Include an abstract move method to move the shape in the x, y, and z directions. Derive the Point class from ZeroDimensionalShape. Give the point class an X, Y, and Z coordinate, and provide methods to get and set the coordinates . Derive the Line class from OneDimensionalShape. One dimensional shapes have an abstract getLength0 method. The line class is constructed using two points, example: new Line (new Point (o,o,0),new Point (4,4,4)) creates a line from location 0,0,0 to location 4,4,4. . Derive the Circle class from TwoDimensionalShape. Two dimensional shapes have a abstract getArea0 method. The circle class is constructed using a point for the center, and a radius, example: new Circle (new Point (2,2,2),2) creates a circle centered at 2,2,2 with a radius of 2. Assume the circle has the same Z value for all points in the circle. . Derive the Sphere class from ThreeDimensionalShape. Three dimensional shapes have both a abstract getArea0 and abstract getVolume0 methods. The sphere class is constructed using a point for the center, and a radius, example: new Sphere (new Point (2,2,2), 2) creates a sphere centered at 2,2,2 with a radius of 2 . Include a toString0 that returns a String description of the key properties of each object, including its ID . Use a ShapeTester program to test the Shape hierarchy. Ilustrate the use of polymorphism ur tester. For example, first create an array of Shapes. Using loops, print the current in yo location, move the shapes, and print the new location (See Sample Tester Code below)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!