Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask C/C++ Expert


Home >> C/C++

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

C/C++, Programming

  • Category:- C/C++
  • Reference No.:- M91726458
  • Price:- $75

Priced at Now at $75, Verified Solution

Have any Question?


Related Questions in C/C++

What are the legal requirements with which websites must

What are the legal requirements with which websites must comply in order to meet the needs of persons with disabilities? Why is maximizing accessibility important to everyone?

Assignment word matchingwhats a six-letter word that has an

Assignment: Word Matching What's a six-letter word that has an e as its first, third, and fifth letter? Can you find an anagram of pine grave. Or how about a word that starts and ends with ant (other than ant itself, of ...

Question 1find the minimum and maximum of a list of numbers

Question: 1. Find the Minimum and Maximum of a List of Numbers: 10 points File: find_min_max.cpp Write a program that reads some number of integers from the user and finds the minimum and maximum numbers in this list. Th ...

Software development fundamentals assignment 1 -details amp

Software Development Fundamentals Assignment 1 - Details & Problems - In this assignment, you are required to answer the short questions, identify error in the code, give output of the code and develop three C# Console P ...

Why do researcher drop the ewaste and where does it end

Why do researcher drop the ewaste and where does it end up?

1 implement the binary search tree bst in c using the node

1. Implement the Binary Search Tree (BST) in C++, using the Node class template provided below. Please read the provided helper methods in class BST, especially for deleteValue(), make sure you get a fully understanding ...

Project - space race part a console Project - Space Race Part A: Console Implementation

Project - Space Race Part A: Console Implementation INTRODUCTION This assignment aims to give you a real problem-solving experience, similar to what you might encounter in the workplace. You have been hired to complete a ...

There are several ways to calculate the pulse width of a

There are several ways to calculate the pulse width of a digital input signal. One method is to directly read the input pin and another method (more efficient) is to use a timer and pin change interrupt. Function startTi ...

Assign ment - genetic algorithmin this assignment you will

ASSIGN MENT - GENETIC ALGORITHM In this assignment, you will use your C programming skills to build a simple Genetic Algorithm. DESCRIPTION OF THE PROGRAM - CORE REQUIREMENTS - REQ1: Command-line arguments The user of yo ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As