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

  User and prints the number of occurrences of each letter

File CountLetters.java contains a program that reads a word from the user and prints the number of occurrences of each letter in the word. In reviewing the code, note that the word is converted to all upper case first, then each letter is translated ..

  Discuss quasi-experimental designs

Jackson (2012), even-numbered chapter exercises, p 360. Describe the advantages and disadvantages of quasi-experiments? What is the fundamental weakness of a quasi-experimental design? Why is it a weakness? Does its weakness always matter?

  Demonstrate your knowledge in a pragmatic way

Summarize everything that we have addressed in the XML Applications course, and provide a mechanism to demonstrate your knowledge in a pragmatic way.

  Create a simple votingmachine

In this exercise you will create a simple VotingMachine. In the United States, when a candidate runs for office, the person is often identified as a Democrat, Republican, or Independent

  Write java program to read present basic hourly wage

Write down a java program which will input 1. Read present basic hourly wage. Read in workers fist name and socond name.

  Write a program called gf2java to implement the finite

write a program called gf2.java to implement the finite field gfpn where p is a prime number and n is a positive

  Benefits of using java as a programming language

What are the benefits of using Java as a programming language? Discuss how the use of an integrated development environment (IDE) such as Eclipse enhances programmer productivity

  Java program to implement currency converter

Write a JAVA program that helps the user convert currency. The user will enter the amount in Kuwaiti dinars. The program will print the equivalent amount in US dollar and Euros count his change.

  Find what kind of output best shows off the operation

Find what kind of output best shows off the operation of these classes, and write a program that produces that kind of output.

  Program that will calculate monthly mortgage payments

Consumers think of the term of the loan in years, not months.  It would still be good to tell them how many monthly payments they will be making.

  Program that computes the annual road tax

All cars registered on or before 1 March 2001 are charged according to their engine size (in cc). A car with an engine size of less than or equal to 1550cc is charged at 110 GBP; otherwise it is charged at 165 GBP.

  Calculates the square root of each number

Write a Java program that reads in 10 integers and displays the biggest and second biggest number from them.

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