Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a project called genericshapes that will implement and use a generic class. The generic Class represents a Cuboid with length, breadth and height. The

  1. Create a project called genericshapes that will implement and use a generic class. The generic Class represents a Cuboid with length, breadth and height. The generic type will be used to accept the dimensions values either as integers or as decimal numbers.
    1. Create a generic class called Cuboid that will store the three dimensions of a cuboid length, breadth and height. Add the getters and setters for the dimensions.
    2. Override the toString() method so that it returns all of the dimensions as a string.
    3. The type of the dimensions will be decided at construction of the cuboid instance. Example: Cuboid c1 = new Cuboid();
    4. The Class Cuboid must only accept values of the type Number (predefined in Java), or a subtype of Number, as a generic type for the dimensions.
    5. Add a method to the class that returns the volume of a Cuboid as a Double (l*b*h).
    6. Use the Cuboid class: create an instance doubleCuboid of the Cuboid class with the Double type and set the dimensions to custom decimal values.
    7. create an instance integerCuboid of the Cuboid class with the Integer type and set the dimensions to custom integer values.
    8. In the client class display the result of calling the getVolume() method on both the doubleCuboid and integerCuboid instances.

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

Visual C# And Databases

Authors: Philip Conrod, Lou Tylee

16th Edition

1951077083, 978-1951077082

Students also viewed these Databases questions

Question

= 7. Identify the two pillars of the Toyota Production System.

Answered: 1 week ago