Complete the polyhedron hierarchy

Assignment Help JAVA Programming
Reference no: EM131026731

1. The Problem

This assignment deals with a program takes three types of Polyhedra from an input file and constructs the appropriate objects.

In this exercise, you will be completing the Polyhedron Hierarchy-specifically the Composite class.

In this assignment, you will be solving a similiar problem, in Java.

1 Input

The program reads data from one file, polyhedra1.txt. File extensions on Linux may be arbitrary-i.e., this file could have been named with .dat as the extension.

sphere 1
cylinder 2 1
sphere 4
cylinder 2 3
composite 3
    sphere 3
    sphere 5
    sphere 7

composite 2
    cylinder 1 2
sphere 5
sphere 3

Each polyhedron line is formatted as a keyword-i.e., the name of the polyhedron-and all appropriate attributes. A sphere is defined by a radius:

sphere 1

A cylinder with height 2 and radius 3 would take the form:
cylinder 2 3

A composite shape us defined by an integer representing the number, n, of polyhedra of which it is composed. It is then followed by n polyhedron input entries:

composite 2
cylinder 1 2
sphere 5

You may assume a valid input file. All input is well-formed.

1.2 Output

The output consists of two reports written to standard output, one after the other.

1. A report listing all polyhedra that were read from polyhedra1.txt.

2. A report listing the result of scaling all polyhedra.

If the program is run with the polyhedra1.txt as the input file, the following output should be generated:

Original Polyhedra
------------------------------------------------------------
[Sphere] (2.0, 2.0, 2.0)->Radius: 1.0 Diameter: 2.0
[Cylinder] (2.0, 2.0, 2.0)->Radius: 1.0 Height: 2.0
[Sphere] (8.0, 8.0, 8.0)->Radius: 4.0 Diameter: 8.0
[Cylinder] (6.0, 6.0, 2.0)->Radius: 3.0 Height: 2.0
[Composite] (14.0, 14.0, 14.0)->3 polyhedra
 [Sphere] (6.0, 6.0, 6.0)->Radius: 3.0 Diameter: 6.0
 [Sphere] (10.0, 10.0, 10.0)->Radius: 5.0 Diameter: 10.0
 [Sphere] (14.0, 14.0, 14.0)->Radius: 7.0 Diameter: 14.0

[Composite] (10.0, 10.0, 10.0)->2 polyhedra
 [Cylinder] (4.0, 4.0, 1.0)->Radius: 2.0 Height: 1.0
 [Sphere] (10.0, 10.0, 10.0)->Radius: 5.0 Diameter: 10.0

[Sphere] (6.0, 6.0, 6.0)->Radius: 3.0 Diameter: 6.0

Scaled Polyhedra (Clones)
------------------------------------------------------------
[Sphere] (4.0, 4.0, 4.0)->Radius: 2.0 Diameter: 4.0
[Cylinder] (4.0, 4.0, 4.0)->Radius: 2.0 Height: 4.0
[Sphere] (16.0, 16.0, 16.0)->Radius: 8.0 Diameter: 16.0
[Cylinder] (12.0, 12.0, 4.0)->Radius: 6.0 Height: 4.0
[Composite] (28.0, 28.0, 28.0)->3 polyhedra
 [Sphere] (12.0, 12.0, 12.0)->Radius: 6.0 Diameter: 12.0
 [Sphere] (20.0, 20.0, 20.0)->Radius: 10.0 Diameter: 20.0
 [Sphere] (28.0, 28.0, 28.0)->Radius: 14.0 Diameter: 28.0

[Composite] (20.0, 20.0, 20.0)->2 polyhedra
 [Cylinder] (8.0, 8.0, 2.0)->Radius: 4.0 Height: 2.0
 [Sphere] (20.0, 20.0, 20.0)->Radius: 10.0 Diameter: 20.0

The easiest way to see generate the expected output is to run the sample executable solution I have provided. These two files are named as command-line parameters when the program is executed.

For example, if the sample data above is kept in polyhedra1.txt, to run this program, type:
java -jar CreatePolyhedra.jar polyhedra1.txt 2

Run the compiled solution with both the provided input file and your own test input files.

Once you have completed your solution, compare the output generated by your solution to the output generated by my solution. The two sets must be identical.

(On a Windows system, you would omit the "./". If you are running from Eclipse or a similar development environment, you may need to review how to supply command-line parameters to a running program.)

Your Tasks

Complete clone (copy constructor portion), scale, and toString functions for Composite class.
- Note that I have provided you a clone function and a skeleton for a copy constructor. Complete the copy constructor.
- Note the hints in the toString function.

Attachment:- Java.zip

Reference no: EM131026731

Questions Cloud

Find the orthogonal projection p of e^x onto x : Consider vector space C[0,1] with scalar product: for any two functions f(x), g(x)
What do employers want from their potential employees : What do employers want from their potential employees - Read through each article listed below on how to effectively interview, to negotiating your salary and first job.
What halfreaction would be occurring at the cathode : For a spontaneous reaction A(aq) + B(aq) → A-(aq) + B+(aq), answer the following question- If you made a voltaic cell out of this reaction, what halfreaction would be occurring at the cathode, and what half-reaction would be occurring at the anode..
Entire course business economics : GM 545 Entire Course Business Economics https://homeworklance.com/downloads/gm-545-entire-course-business-economics/ GM 545 Business Economics Week 1 Supply and Demand (graded)
Complete the polyhedron hierarchy : Program takes three types of Polyhedra from an input file and constructs the appropriate objects - you will be completing the Polyhedron Hierarchy-specifically the Composite class.
Find the matrix representations of formations : S is a subspace of C[0,1] formed by Span(xsinx, xcosx,sinx,cosx)and L is the differential operator: L(f(x)=f'x(x). Note use the vectors forming the span as basic vectors
What is the rate constant for the decay : The accompanying graph illustrates the decay of 4288Mox which decays via positron emission. What is the half-life of the decay? What is the rate constant for the decay?
What is polymorphism concept means and give an example : what this concept means and give an example to illustrate your understanding of the topic. You must use Java classes and Java interfaces to help with your description.
Does either one of these formulas define a norm : Does either one of these formulas define a norm? If yes, show that all three axioms of norm hold. If no, demonstrate which axiom fails.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Compare the average completion times of all jobs

Compare the average completion times of all jobs for each scheduling algorithm. Output the details of each algorithm's execution. You need to show which jobs are selected at what times as well as their starting and stopping burst values. You can choo..

  Calculate payback period and net present value

Calculate payback period (PBP), net present value (NPV), and internal rate of return (IRR). Which project do you recommend for development? Support your recommendation.

  Write a program in java that reads a file

Write a program in Java that reads a file of numbers of type int and outputs all the numbers to another file, but without there being any duplicate numbers.

  How can i support https in a servlet

1) What is SSL? 2) How can I support HTTPS (SSL) in a servlet? 3) How can I download a file (for instance, a Microsoft Word document) from a server using a servlet and an applet?

  Make an explicit statement of the invariant of the set class

Write a new container class called ser, which is similar to a bag, except that a set can contain only one copy of any given item, You will need to change the interface a bit. For example, instead of the bag's count function, you'll want a constant..

  Write java statements that use a for each loop to cycle

Write java statements that use a for each loop to cycle through all the elements in an ArrayList of doubles named grades.

  Client class to test implementation of the vector class

Write a client class to test your implementation of the Vector3D class thatyou implemented. Name the package in which this class is defined (projectname) vector3dapp.

  What is the greatest common divisor

What is the greatest common divisor of the Fibonacci numbers f100 and f101 by Euclid algorithm.

  Display a list of entries in a jtextarea or jtable

Create a GUI-based program to accept name of donor, name of charity, and amount of pledge from the user. Display a list of entries in a JTextArea or JTable

  Java program that plays a guessing game with the user

The user must be allowed to play until deciding to explicitly terminate the game (I would use an exit button on the GUI window).

  Write program in java that solves system of linear equations

Write a program in java that solves system of linear equations. Users should be able to input the number of variables.

  Create an application named numbers.

Create an application named Numbers. The Numbers class should have non-static public methods named sum and difference, each taking a pair of int variables as arguments. As you might expect, the sum method should add the two integers and return the..

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