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

  Implement the client and server components

The basic requirements of this assignment are to implement the client and server components as discussed above. The basic protocol of the system is described below: The operations of the client are: SEND_SERVER_MESG: send a basic text message to th..

  Objectives1 to practice defining classes using separate

objectives1. to practice defining classes using separate compilation.2. to practice using classes vectors and

  Combine the four loop problems into one program

Combine the four loop problems into one program with four distinct methods (the data is in the attached document). For this problem you will write methods, two value returning methods and two void methods.

  String that contains at least five letters

Write an application that prompts the user for a String that contains at least five letters and at least five digits. Continuously reprompt the user until a valid String is entered. Display a message indicating whether the user was successful or did ..

  Java program asks the user to input the number of gallons

Write a java program asks the user to input the number of gallons of gas in the tank and the price of gas per gallon

  Java coding if-else while loop

Code a while loop that keeps printing "You are a DEDICATED student!" as long as the user enters an attendance rate of 90% or greater. Assume the loop-control variable, attendance, is already declared along with input for the Scanner class. The w..

  Constructs a lock with a given combination.

A combination lock has a dial with 26 positions labeled A..Z. The dial needs to be set three times. If it is set to the correct combination, the lock can be opened.

  Explain where the following method invocations

Explain where the following method invocations are most likely to be found in a program for dealing with census data organized using the Model, View, Controller (MVC) design pattern. Choices are zero or more of Model, View, and Controller. Be sure to..

  Write an application in which the user can enter a date

Write an application in which the user can enter a date using digits and slashes (for example, " 6/24/2012 " ), and receive output that displays the date with the month shown as a word

  Write a program called inheritancetest java

Write a program called InheritanceTest.java to support an inheritance hierarchy for class Point-Square-Cube. Use Point as the superclass of the hierarchy. Specify the instance variables and methods for each class.

  What is a java archive

What type of output does the javadoc command generate and how do you view the output and what is a Java archive?

  Write a reference class called ctatrain

writing a reference class that consist of the 2nd and 3rd instance variables below. my class should consist of an array of values in the 2nd instance variable

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