Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need corrections to the following java code, included are the compiler error messages: Implement the Shape hierarchy -- create an abstract class called Shape, which

Need corrections to the following java code, included are the compiler error messages:

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Implement the Shape hierarchy -- create an abstract class called Shape, which will be the parent class to TwoDimensionalShape and ThreeDimensionalShape. The classes Circle, Square, and Triangle should inherit from TwoDimensionalShape, while Sphere, Cube, and Tetrahedron should inherit from ThreeDimensionalShape. Each TwoDimensionalShape should have the methods getArea() and getPerimeter(), which calculate the area and perimeter of the shape, respectively. Every ThreeDimensionalShape should have the methods getArea() and getVolume(), which respectively calculate the surface area and volume of the shape. Every class should have a member variable containing its dimensions -- for example, the Circle class should have a member variable describing its radius, while the Triangle class should have three member variables describing the length of each side. Note that the Tetrahedron cass should describe a regular tetrahedron, and as such, should only have one member variable. Create a Driver class with a main method to test your Shape hierarchy. The program should prompt the user to enter the type of shape they'd like to create, and then the shape's dimensions. If the shape is two dimensional, the program should print its area and its perimeter, and if it's a three dimensional shape, its surface area and volume. COMPILER ERROR MESSAGES Driver.java: 30: error: cannot find symbol TwoDimensionalshape c= new Circle(rad); symbol: class TwoDimensionalshape location: class Driver Driver.java:30: error: cannot find symbol TwoDimensionalshape c= new Circle (rad); symbol: class Circle location: class Driver Driver.java:41: error: cannot find symbol TwoDimensionalshape s = new Square (side1); symbol: class TwoDimensionalshape location: class Driver Driver.java:41: error: cannot find symbol TwoDimensionalShape s = new Square(side1); symbol: class square location: class Driver Driver.java: 57: error: cannot find symbol TwoDimensionalshape r = new Triangle(s1,s2,s3); symbol: class Twodimensionalshape location: class Driver Driver.java:57: error: cannot find symbol TwoDimensionalShape r = new Triangle(s1,s2,s3); symbol: class Triangle location: class Driver Driver.java:76: error: cannot find symbol ThreeDimensionalShape cc2= new Sphere (radx); symbol: class Threedimensionalshape location: class Driver Driver.java:76: error: cannot find symbol ThreeDimensionalShape cc2 = new Sphere (radx); symbol: class Sphere location: class Driver Driver.java:89: error: cannot find symbol ThreeDimensionalShape cc1= new Cube(sx); symbol: class Threedimensionalshape location: class Driver Driver.java:89: error: cannot find symbol ThreeDimensionalShape cc1 = new Cube (sx)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Next Generation Databases NoSQLand Big Data

Authors: Guy Harrison

1st Edition

1484213300, 978-1484213308

More Books

Students also viewed these Databases questions