Implement the polyhedron interface

Assignment Help C/C++ Programming
Reference no: EM131010764

This program needs to be done in a C++ software, the details are in the file.

1. The Problem

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

Sphere
Cylinder
Composite

The former two of these items are read as Polyhedra objects. A Composite Polyhedron is composed of one or more Polyhedra. The provided operator>> in Polyhedron.h

handles this mapping (through the PolyhedronFactory class). All three classes implement the Polyhedron interface.

In this exercise, you will be completing the Polyhedron Hierarchy-specifically the Cylinder and Composite classes.

1.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.

The scaling parameter is specified as the second command line argument.
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, 2, 2)->Radius: 1 Diameter: 2

[Cylinder] (2, 2, 2)->Radius: 1 Height: 2

[Sphere] (8, 8, 8)->Radius: 4 Diameter: 8

[Cylinder] (6, 6, 2)->Radius: 3 Height: 2

[Composite] (14, 14, 14)->3 polyhedra

[Sphere] (6, 6, 6)->Radius: 3 Diameter: 6

[Sphere] (10, 10, 10)->Radius: 5 Diameter: 10

[Sphere] (14, 14, 14)->Radius: 7 Diameter: 14

[Composite] (10, 10, 10)->2 polyhedra

[Cylinder] (4, 4, 1)->Radius: 2 Height: 1

[Sphere] (10, 10, 10)->Radius: 5 Diameter: 10

[Sphere] (6, 6, 6)->Radius: 3 Diameter: 6

Scaled Polyhedra (Clones)

------------------------------------------------------

[Sphere] (4, 4, 4)->Radius: 2 Diameter: 4

[Cylinder] (4, 4, 4)->Radius: 2 Height: 4

[Sphere] (16, 16, 16)->Radius: 8 Diameter: 16

[Cylinder] (12, 12, 4)->Radius: 6 Height: 4

[Composite] (28, 28, 28)->3 polyhedra

[Sphere] (12, 12, 12)->Radius: 6 Diameter: 12

[Sphere] (20, 20, 20)->Radius: 10 Diameter: 20

[Sphere] (28, 28, 28)->Radius: 14 Diameter: 28

[Composite] (20, 20, 20)->2 polyhedra

[Cylinder] (8, 8, 2)->Radius: 4 Height: 2

[Sphere] (20, 20, 20)->Radius: 10 Diameter: 20

[Sphere] (12, 12, 12)->Radius: 6 Diameter: 12

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:

./createPolyhedra 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.

1.3 Your Tasks

1. Complete display, read, clone, and scale functions for Cylinder and Composite.

2. Complete the Big-3 for Composite

3. Note that the Composite::polyhedra attribute, Polyhedron** polyhedra is an array of pointers. You will need to make use of the appropriate new, delete, and delete[] commands.

4. While you should strive to complete these functions without introducing memory leaks, memory leaks will not be evaluated during grading.

5. You may add supplemental member function to the Cylinder (Cylinder.h and Cylinder.cpp)
2. Mechanics
2.1 Grading

Tests 000 through 006 evaluate your program as a whole:

Test 000 confirms that your code compiles and runs. This test discards all output.

Tests 001-002 evaluate how your program runs given input file consisting only of Cylinder objects. These tests disregard output formatting.

Test 003-004 evaluate how your program runs given input file consisting only of Composite objects. These tests disregard output formatting.

Test 005-006 evaluate how your program runs given input file consisting of both Cylinder and Composite objects. Theses tests include output formatting.

With the exception of Test 000, each of the above:

Odd numbered tests apply a scaling factor of 1 (i.e., do not evaluate your scaling functions).

Even numbered tests apply a scaling factor

Attachment:- polyhedra oop.zip

Reference no: EM131010764

Questions Cloud

How do you plan to apply your degree upon graduating : How do you plan to apply your degree upon graduating from the Information Technology masters program?
Discuss the legal issues regarding mel and opie claims : Mel purchased a large piece of land in Goodtown. To the north of the land was North Road and to the south was South Road. Access was via the very busy South Road as the land was separated from North Road by a narrow strip of land which was not par..
Does anyone have templates for project management : Does anyone have templates for project management? (i.e. Project Scope Statements, Work Breakdown Structure, Change Management Process, etc)
Find revenue function from sale of x pairs of running shoes : Find the revenue function R(x) from the sale of x pairs of running shoes, and state its domain. Evaluate the marginal revenue at x=325 and x=425 and interpret the results.
Implement the polyhedron interface : This assignment deals with a program takes three types of Polyhedra from an input file and constructs the appropriate objects.
Find the rate of change function for the number of bicycles : Find the rate of change function for the number of bicycles assembled with respect of time. Find and interpret M' (2) and M' (5).
Explore the importance of culture : Your 3,000 word essay must explore the importance of culture, investment and regeneration within the city you have chosen, and should also discuss the issues which arise as a result of culture and diversity within the city
Determine the exact profit from the sale : A company has found that the profit (in dollars) from the sale of x ovens. Determine the exact profit from the sale of the 39th oven. Use the marginal profit to estimate the profit from the 39th oven sold.
U.s. did make maternity leave a requirement : Describe the balance that you currently seek between career and family life. Do you believe that the mindset of corporate America is conducive to the type of work and family arrangement that would suit you? Explain the major reasons why or why not..

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Program that takes the purchase price of two item

Program that takes the purchase price of two items and compares the prices of those items under two different discounts (half-off the second item, and a percentage off both items (i.e. 10% off)).

  Implement class bankacct for bank usq

Implement class BankAcct, for Bank of USQ, using bankacct.cpp and bankacct.h and Implement an application bankUSQ_app.cpp

  Write a c++ program that reads a set of integers

Write a c++ program that reads a set of integers and then finds and prints the sums of the even and odd numbers.

  The actual solution of the equation shall be done

The actual solution of the equation shall be done by a function named equSolver(), which takes three coefficients as parameters and returns a structure of three fields: two roots (if they exist) and a boolean indicator, whether the roots do exist.

  What are the values of queuefront and queuerear

What are the value of queueFront and queueRear after removing an element from the queue? Also what was the position of the removal queue element?

  Calculate the modified value of the first character of input

To calculate the modified value of the first character of input we add its mapped value to the mapped value from the first character of the encryption string.

  Finish or complete the coding for me because syntax and code

finish or complete the coding for me. because syntax  and codes, so the proram can execute correctly

  Computer programming

Computer programming

  Ansi-c program complete assignment as per written in the

complete assignment as per written in the attached

  Main function to input twenty integers in given range

Write a main function to input 20 integers in range of 1-6, function should count number of times the numbers 2 and 5 occur. function must declare statics variables count2 and count5.

  Write a program in c++ to read a text file

Write a program in C++ to read a text file (containing more than 500 words), count its alphabets, digits, special characters, capital and small letters, number prepositions and count for each word.

  Explain how priority queue list works

Hi. I have done a priority queue list. We have been giving test code to test our list. I will post what I have along with the issues. I keep getting an error with the getelement() part in the main program where we are supposed to print out the ele..

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