Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this assignment, you are going to implement the following design using the interface files I_twoD.java and I_threeD.java . I_twoD.java : /* This is an

In this assignment, you are going to implement the following design using the interface files I_twoD.javaimage text in transcribedimage text in transcribed and I_threeD.javaimage text in transcribedimage text in transcribed.

I_twoD.java :

/*

This is an interface file to compute the area and the perimeter of a 2D

shape object.

*/

package assignment3;

public interface I_twoD {

float computeArea();

float computePerimeter();

}

I_threeD.java :

/*

This is an interface file to compute volume of a 3D shape object.

*/

package assignment3;

public interface I_threeD {

float computeVolume();

}

image text in transcribed

Shape class is the super abstract class in the hierarchy. And we have 2 interfaces, I_twoD and I_threeD. Cube class is a 3-dimensional object, hence it implements the I_threeD interface, in contrast Square and Circle classes are 2-dimensional objects, and they implement the I_twoD interface.

In addition, Cube is an extension of the Square class.

As an overall, you are going to implement 4 classes Shape, Cube, Square and Circle in 4 files; Shape.java, Cube.java, Square.java, and Circle.java respectively and also main test driver class in the file Assignment3.java.

In the print function, please print the type, the name, and the quantitative parameter of the shape (either radius or side).

Please use the following main function in your implementation:

public static void main(String[] args) {

// TODO code application logic here

Circle circle = new Circle(Color.RED, "myCircle", 2.f);

circle.print();

System.out.println("Area : "+circle.computeArea());

System.out.println("Perimeter : "+circle.computePerimeter());

Square square = new Square(Color.BLUE, "mySquare", 3.5f);

square.print();

System.out.println("Area : "+square.computeArea());

System.out.println("Perimeter : "+square.computePerimeter());

Cube cube = new Cube(Color.CYAN, "myCube", 2.3f);

cube.print();

System.out.println("Volume : "+cube.computeVolume());

}

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_2

Step: 3

blur-text-image_3

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

Practical Database Programming With Visual Basic.NET

Authors: Ying Bai

1st Edition

0521712351, 978-0521712354

More Books

Students also viewed these Databases questions

Question

What is meant by the term brand equity?

Answered: 1 week ago

Question

b. Does senior management trust the team?

Answered: 1 week ago

Question

How will the members be held accountable?

Answered: 1 week ago