Maybe my other thread was too wordy for everyone, cuz I usually receive help right away, and I see that it was viewed 20+ times and yet no responses...so basically I need help with my homework...We were given a main.cpp file, and PART of a header file. He also gave us what our final output should look like. We must generate the implementation file and finish the header to work appropriately. Here's what's given and what I've attempted so far:

main:

``````// The following is the main.cpp file
// which executes your solution and generates the output
// shown below

#include <iostream>
#include "shapes.h"
using namespace std;

int main()
{

ShapeArr  arr(3);

cout << "Rectangles *******"<<endl;
arr.publishStats();

cout << "Circles *******"<<endl;
ShapeArr arr2(3);
arr2.publishStats();

cout << "Triangles *******"<<endl;
ShapeArr arr3(3);
// Note that angles are in Radians (NOT degrees)
arr3.publishStats();

cout << "Regular Polygon *******"<<endl;
ShapeArr arr4(3);
arr4.publishStats();

cout << "Mixture *******"<<endl;
ShapeArr arr5(4);
arr5.publishStats();

}``````

``````// shapes.h file with a few holes to fill in

#include <iostream>
using namespace std;
#include <cmath>

const double PI = 3.14159265359;
const double PI2 = 2*PI;

class Shape
{
public:
Shape()
{
}
virtual double getPerimeter()=0;
virtual double getArea()=0;

double getAPRatio()
{
double p = getPerimeter();
if (p == 0.0) return 0.0; // indeterminant
return getArea()/p;
}
virtual ~Shape()
{ // When everything is freed up properly,

cout << "Shape Destructor"<<endl;
};
};

class Circle : public Shape
{
// Fill in details
private:
public:
double getPerimeter();
double getArea();
};

class Rectangle : public Shape
{
// Fill in details
private:
double height;
double width;
public:
double getPerimeter();
double getArea();
};

class Triangle : public Shape
{
// Fill in details
private:
double sideA;
double sideB;
double includedAngle;
public:
double getPerimeter();
double getArea();
};

class RegularPoly : public Shape
{
// Fill in details
private:
int numSides;
double side;
public:
double getPerimeter();
double getArea();
};

class ShapeArr
{
// The following is what you need to have an
// array of pointers to the Shape class

Shape ** arr;
int arrSize;

// To allocate this array, you will need something like:
//    arr = new Shape* [arrSize];
// the memory when your ShapeArr class is destructed.
// If you do it correctly, you should see the Shape Destructor
// generate it's cout statement for every Shape class created.

// It's useful to keep track of the number of Shapes added to
// the array.

int currCount;
public:
ShapeArr(int arrSize);
~ShapeArr();
void addTriangle(double sideA, double includedAngle, double sideB);

// This routine prints out the Max getAPRatio and the average
// getAPRatio for all of the Shapes in this class.

void publishStats();
};``````

My implementation file attempt so far:

``````#include <iostream>
#include "shapes.h"
using namespace std;

double Rectangle::getPerimeter()
{
double p;
p = height + width;
return p;
}

double Circle::getPerimeter()
{
double p;
return p;
}

double Triangle::getPerimeter()
{
double p;
p = sideA + sideB + sqrt(sideA*sideA + sideB*sideB - 2.0*sideA*sideB*cos(includedAngle));
return p;
}

double RegularPoly::getPerimeter()
{
double p;
p = height + width;
return p;
}

ShapeArr::ShapeArr(int arrSize)
{
this -> arrSize = arrSize;
currCount = 0;
arr = new Shape* [arrSize];
}

ShapeArr::~ShapeArr()
{
delete [] arr;
}

{
//Shape * s;
currCount++;
//s->getPerimeter();
}

{
currCount++;
}

void ShapeArr::addTriangle(double sideA, double includedAngle, double sideB)
{
currCount++;
}

{
currCount++;
}

// This routine prints out the Max getAPRatio and the average
// getAPRatio for all of the Shapes in this class.

void ShapeArr::publishStats()
{
}``````

And what the final output should look like:

``````Rectangles *******
Max APRatio = 0.6 Average APRatio=0.477778
Circles *******
Max APRatio = 1.5 Average APRatio=1
Triangles *******
Max APRatio = 0.193977 Average APRatio=0.140715
Regular Polygon *******
Max APRatio = 3.97364 Average APRatio=1.62913
Mixture *******
Max APRatio = 3.97364 Average APRatio=1.43676
Shape Destructor
Shape Destructor
Shape Destructor
Shape Destructor
Shape Destructor
Shape Destructor
Shape Destructor
Shape Destructor
Shape Destructor
Shape Destructor
Shape Destructor
Shape Destructor
Shape Destructor
Shape Destructor
Shape Destructor
Shape Destructor``````

Oh, and moderators, feel free to delete my other thread or whatever since it is pretty similar to this one, yet more confusing...Hopefully this one is easier for someone to help me with. Sorry bout the confusion!!

Understood, but considering I'm at home right now, I was hoping someone on here could help me....?

Can ANYONE tell me what I need to code or call in my 'add' functions!?

I assume it needs to begin like this:
What else do I need though??
How do I incorporate the height and width into it? Do I need to call getPerimeter from here, or do i wait until i get to the publishStats func.??

``````void ShapeArr::addRectangle(double height, double width)
{
if (currCount < arrSize)
arr[currCount++] = new Rectangle;
}``````