Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please use c++ thank you. EDIT: Sorry this is the geometric object class #ifndef GEOMETRICOBJECT_H #define GEOMETRICOBJECT_H #include using namespace std; class GeometricObject { public:

Please use c++ thank you.image text in transcribedEDIT: Sorry this is the geometric object class

#ifndef GEOMETRICOBJECT_H #define GEOMETRICOBJECT_H #include using namespace std;

class GeometricObject { public: GeometricObject(); GeometricObject(const string&, bool); string getColor() const; void setColor(const string&); bool isFilled() const; void setFilled(bool); string toString() const;

private: string color; bool filled; };

#endif

#include "GeometricObject.h"

GeometricObject::GeometricObject() { color = "white"; filled = false; } GeometricObject::GeometricObject(const string& color, bool filled) { this->color = color; this->filled = filled; } string GeometricObject::getColor() const { return color; } void GeometricObject::setColor(const string& color) { this->color = color; } bool GeometricObject::isFilled() const { return filled; } void GeometricObject::setFilled(bool filled) { this->filled = filled; } string GeometricObject::toString() const { return "Geometric Object"; }

Programming Exercises that extends 1. (The Triangle class) Design a class named Triangle GeometricObject. The class contains the following: Three double data fields named sidel, side2, and side3 to denote the three sides of the triangle A no-arg constructor that creates a default triangle with each side equal to 1.0 A constructor that creates a triangle with the specified sidel, side2, and side 3 The constant accessor functions for all three data fields A constant function named getArea () that returns the area of this triangle A constant function named getPerimeter() that returns the perimeter of this triangle Draw the UML diagram that involves the classes Triangle and GeometricObject. GeometricObject can be downloaded (header and source file) from the Moodle site. Implement the Triangle class and write a test program that prompts the user to enter the three sides of a triangle, enter a colour and enter 1 or 0 to indicate whether the triangle is filled or not. The program should create a Triangle object with these sides and set the colour and filled properties using the input. The program should then display the area, perimeter, colour, and state true or false to indicate whether it is filled or not. As an example: Input the lengths of the three sides of the triangle: 2.5 4.0 5.5 Enter whether the triangle is filled (1) or not (@): 1 Enter the colour of the triangle: blue You created a blue triangle of area 4.58258 and perimeter 12 Was the triangle filled? true Press any key to continue Note: let a, b, c be the lengths of the sides of the triangle. The area is given by: Area = VP(p a)(p b)(p -c) where p is half of the perimeter (p = (a + b + c) / 2)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Object Databases The Essentials

Authors: Mary E. S. Loomis

1st Edition

020156341X, 978-0201563412

More Books

Students also viewed these Databases questions

Question

9 How can training be evaluated?

Answered: 1 week ago