Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 2: Interfaces As covered in lectures, an interface is a set of methods. When a class implements an interface, the methods in the interface

Part 2: Interfaces

As covered in lectures, an interface is a set of methods. When a class implements an interface, the methods in the interface must be implemented in the class. The methods are not implemented in the interface, just listed.

1. Set up an interface called ThreeDShape that represents a 3D shape. Include an abstract method that allows the calculation of the volume of the 3D shape.

2. Amend the class hierarchy for shape to include two new subclasses representing the 3d shapes, cube and sphere. Get these classes to implement your new interface ThreeDShape. Hint 1: When a class implements an interface, it has to implement all methods in the interface. Hint 2: Implements keyword

3. Implement the area() method for the two new classes (cube and sphere) to return the surface area of the shape.

4. Modify the test class to test the new classes and methods you have added by including the new shapes (cube and sphere)in the array you have setup

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

Murach's SQL Server 2012 For Developers

Authors: Bryan Syverson, Joel Murach, Mike Murach

1st Edition

1890774693, 9781890774691

More Books

Students also viewed these Databases questions

Question

Show that if U( (( V( = W( then U( (( V( = W(.

Answered: 1 week ago

Question

6. Explain how to train managers to coach employees.

Answered: 1 week ago