• You are given a class called Shape, an enumeration called ShapeType, and a starting point to the main function. • Create one class per shape required O Each class should be split into header/implementation files as we described in class o Each class should publicly inherit from the Shape class o Each class should have a fully parametrized constructor The number of parameters in the constructor depend on the values needed to calculate the shape's perimeter and area (one double for circle, two doubles for rectangle, etc.) It should only contain parameters needed for the parameter and area

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

This assignment is not graded, I just need to understand how to do it. Please help, thank you!

Language: C++

Given:

Main.cpp

#include

#include "Shape.h"

using namespace std;

void main() {
   /////// Untouchable Block #1 //////////
   Shape* shape;
   /////// End of Untouchable Block #1 //////////

   /////// Untouchable Block #2 //////////
   if (shape == nullptr) {
       cout << "What shape is this?! Good bye!";
       return;
   }

   cout << "The perimeter of your " << shape->getShapeName() << ": " <<
       shape->getPerimeter() << endl;
   cout << "The area of your " << shape->getShapeName() << ": " <<
       shape->getArea() << endl;
   /////// End of Untouchable Block #2 //////////
}

Shape.cpp

string Shape::getShapeName() {
   switch (mShapeType)    {
   case ShapeType::CIRCLE:
       return "circle";
   case ShapeType::SQUARE:
       return "square";
   case ShapeType::RECTANGLE:
       return "rectangle";
   case ShapeType::TRIANGLE:
       return "triangle";
   default:
       return "unknown shape";
   }
  
   return "unknown shape";
}

ShapeType.h

#pragma once

enum class ShapeType {
   CIRCLE,
   SQUARE,
   RECTANGLE,
   TRIANGLE
};

Shape.h

#pragma once

#include

#include "ShapeType.h"

using namespace std;

class Shape {
private:
   ShapeType mShapeType;
   double mPerimenter;
   double mArea;

public:
   Shape(ShapeType shapeType);
   ~Shape();

protected:
   void setPerimenter(double perimeter);
   void setArea(double area);

public:
   double getPerimeter();
   double getArea();
   ShapeType getShapeType();
   string getShapeName();
};

Problem Description
Let us create an interface where a user can select one of four shapes: circle, square, rectangle, or triangle.
The user then enters information about the selected shape (for example, radius for circle, width and
length for rectangle, etc.). Then the program displays information about the shape (perimeter and area).
Use the following equations for calculation of perimeter and area.
Circle:
P = 2nr, A = ar²
Square:
P = 4s, A = s²
Rectangle:
P = 21 + 2w, A = lw
Triangle:
b+h
P = a + b+ c, A ="
a, b, and c are the sides of the triangle, where b is the base and h is the height
You are given a starting point with some implemented code. Your job is to use this code to complete the
solution to the problem described above.
Technical Requirements
• You are given a class called Shape, an enumeration called ShapeType, and a starting point to
the main function.
• Create one class per shape required
o Each class should be split into header/implementation files as we described in class
o Each class should publicly inherit from the Shape class
O Each class should have a fully parametrized constructor
The number of parameters in the constructor depend on the values needed to
calculate the shape's perimeter and area (one double for circle, two doubles for
rectangle, etc.)
• It should only contain parameters needed for the parameter and area
Transcribed Image Text:Problem Description Let us create an interface where a user can select one of four shapes: circle, square, rectangle, or triangle. The user then enters information about the selected shape (for example, radius for circle, width and length for rectangle, etc.). Then the program displays information about the shape (perimeter and area). Use the following equations for calculation of perimeter and area. Circle: P = 2nr, A = ar² Square: P = 4s, A = s² Rectangle: P = 21 + 2w, A = lw Triangle: b+h P = a + b+ c, A =" a, b, and c are the sides of the triangle, where b is the base and h is the height You are given a starting point with some implemented code. Your job is to use this code to complete the solution to the problem described above. Technical Requirements • You are given a class called Shape, an enumeration called ShapeType, and a starting point to the main function. • Create one class per shape required o Each class should be split into header/implementation files as we described in class o Each class should publicly inherit from the Shape class O Each class should have a fully parametrized constructor The number of parameters in the constructor depend on the values needed to calculate the shape's perimeter and area (one double for circle, two doubles for rectangle, etc.) • It should only contain parameters needed for the parameter and area
calculate the shape's perimeter and area (one double for circle, two doubles for
rectangle, etc.)
• t should only contain parameters needed for the parameter and area
calculation
• Create the base instance by providing the correct ShapeType at construction
time
o Assign calculated perimeter and area using the available functions in Shape
You should not modify any code in Shape, ShapeType, and the two given blocks in the main
function
Spring 2021
Give the user an interface to select the wanted shape and shape information
o Ask the user for the shape, e.g., A for Circle, B for Square, etc.
o Depending on the selected shape, ask for the shape's information
For example, ask for radius if circle was selected, side if square was selected,
etc.
Create the selected shape with the given information and save it in the shape variable,
which was declared in Untouchable Block #1
o If incorrect information is given (such as a letter that does not represent a shape or a
negative value for shape information), create a null shape instead
o The rest of the program should automatically display the correct shape's name,
perimeter, and area to the user
If you create your shapes with the new keyword, make sure you delete them to avoid
memory leaks
Transcribed Image Text:calculate the shape's perimeter and area (one double for circle, two doubles for rectangle, etc.) • t should only contain parameters needed for the parameter and area calculation • Create the base instance by providing the correct ShapeType at construction time o Assign calculated perimeter and area using the available functions in Shape You should not modify any code in Shape, ShapeType, and the two given blocks in the main function Spring 2021 Give the user an interface to select the wanted shape and shape information o Ask the user for the shape, e.g., A for Circle, B for Square, etc. o Depending on the selected shape, ask for the shape's information For example, ask for radius if circle was selected, side if square was selected, etc. Create the selected shape with the given information and save it in the shape variable, which was declared in Untouchable Block #1 o If incorrect information is given (such as a letter that does not represent a shape or a negative value for shape information), create a null shape instead o The rest of the program should automatically display the correct shape's name, perimeter, and area to the user If you create your shapes with the new keyword, make sure you delete them to avoid memory leaks
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY