Create one object of each concrete class -

Assignment Help Computer Engineering
Reference no: EM132107839

Programming Assignment

(Inheritance and Polymorphism)

I. Create a Point3D Class

Create a class to represent a point in Three-Dimensional space. This class will have private int instance variables x, y, and z, to store the coordinates of the point, a constructor, an overridden toString() method to return the coordinates as a String, and "get" methods that return the values of each of the instance variables.

II. Define an Abstract Class to Represent a 3-D Shape

Your Shape class must meet these specifications:

has a private instance variable of class Point3D (aka: a "member object") that stores the center of the shape

For maximum credit, this member object must be created in the Shape3D constructor. I.e., the implementation of the center must be "hidden" from the client code (the test class) and also from all subclasses

overrides toString() to return a string containing the coordinates of the center (hint: call the toString() method of the Point3D class)

has a concrete method that computes and returns the distance of the center of the shape from the origin (i.e., point 0,0,0)

has abstract methods that compute and return the surface area and the volume of a shape

implements Java's Comparable interface so that Shape objects are ordered by volume (ascending)

III. Derive Concrete Subclasses for Sphere, Parallelepiped, Cylinder, and Cone Shapes

The constructor for each of these classes takes parameters for the x, y, and z coordinates of the center. In addition, the Sphere constructor takes the radius, the Parallelepiped constructor the length, width, and height, the Cone constructor the height and radius, and the Cylinder constructor the radius and height

Since these are concrete classes, each must implement the methods that compute/return the surface area and the volume

Each class will also override toString to return a string containing the class name, coordinates of the center, and the other data values (radius, length, width, etc.)

IV. Write a Driver Class to Test Your Shape Hierarchy

Create one object of each concrete class - using the data given below - and store them in an array of Shapes. The data can be "hardwired" into the code, no need for user input

Using a loop, traverse the array and print the following information for each object - the actual class of the shape (Sphere, Cone, etc), all the input data, and the surface area and volume.

Sort the array in ascending order by volume. This must be done via a call to a sort method of the Arrays class.

Using a loop, print ONLY the class name and volume for each object in the sorted array.

Sort the array again, but this time in descending order by the distance from the origin. This must be done via a call to a sort method of the Arrays class.

Hint: create a class that implements the Comparator interface. Remember that when you implement the compare() method, you get to say what the "natural order" of the objects of your class is.

Using a loop, print ONLY the class name and distance from the origin for each object in the sorted array.

V. Test Data to be Used

Sphere: Center at (2,-8,5), radius of 13

Parallelepiped: Center at (7,2,9), length 37, width 12, height 9

Cylinder: Center at (3,-4,5), radius 11, height 13

Cone: Center at (-5,2,-1), radius 10, height 14

Reference no: EM132107839

Questions Cloud

Brief summary of assessment : Write a brief summary of your assessment that combines your findings from parts (a) through (c).
Displays the conversion of an entered number of dollars : Write a program named Dollars that calculates and displays the conversion of an entered number of dollars into currency denominations-20s, 10s, 5s, and 1s.
Create a new class called circle inside of the project : Make sure you fully comment this code (to start you may well want to select "Generate Comments" when you build the class.
Write a program named tests that declares five variables : Modify the Tests program to create a new one named TestsInteractive that accepts five test scores from a user.
Create one object of each concrete class - : Create one object of each concrete class - using the data given below - and store them in an array of Shapes.
How does this research study contribute to the field : Describe what you will do to complete it. List the types of resources and information you will need to obtain in order to complete each task.
Explain simmels thesis regarding how group size impacts : Simmel was primarily concerned with an examination of group size and distance in terms of impact on form and type of social interaction.
Describe the goals of the group or team : Imagine you have been asked to create a team at work to meet a specific need within your company. Describe what type of group/team this will be.
What does racism mean to you personally : What is the first word that comes to your mind when I say "white"? "Black"? What does racism mean to you personally?

Reviews

Write a Review

Computer Engineering Questions & Answers

  Define how the lack of metrics for measuring

define how the lack of metrics for measuring certain software properties affects the software engineering discipline.

  What would this mean for big-o performance

The alternative implementation of the Queue ADT is to use a list such that the rear of queue is at the end of list. What would this mean for Big-O performance?

  Make a form for a car rental company

The number of days that the customer would have the car will be determined by the difference between the current date and the future date selected on the calendar.

  Find out which servers might need more system resources

define what components she'll need to add or upgrade, at minimum, to make Nichol's servers capable of running Windows Server 2008. Also, explain why you don't recommend leaving all the servers at the minimum hardware requirements. Write down four ..

  Convert these decimal numbers to 8-bit 2s complement binary

Convert these decimal numbers to 8-bit 2's complement binary numbers.

  Using a simulator the boson simulator

Using a simulator the boson simulator (or routers) I want to create a four router topology. Using any interfaces of my choice. I am given /24 networks - choosing interface addresses from the given network ID.

  Create a shadow on phrase html5 canvas

Create a shadow on phrase "HTML5 Canvas"

  Write a php script that computes total cost of ordered bulbs

Write a PHP script that computes the total cost of the ordered light bulbs from below Exercise after adding 6.2 percent sales tax.

  Reverse polish notation

Transform the following numerical arithmetic expression into the reverse Polish notation and display the stack operations in order evaluate the numerical result.

  What is the difference between ide and sata

When you would have a need to use RAID? Explain. What is the difference between integrated drive electronics and serial advanced technology attachment?

  What potential problems may you encounter

Your company currently has several databases and many database management applications to manage the data, including Access, Microsoft SQL, and Oracle.

  Why the graph you provided gave a good visual representation

Write an essay of 2-3 pages that contains the following: Explain why the graph you provided gave a good visual representation of the data.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd