I need the implementation files which are triangle.cpp , rectangle.cpp, color.cp
ID: 3666888 • Letter: I
Question
I need the implementation files which are triangle.cpp , rectangle.cpp, color.cpp and a header file which is shape.h // color.h /I Color class models the color of an item // Use the contents of this file to implement color.cpp / DO NOT MODIFY OR SUBMIT THIS FILE #include using namespace std; #1fndef COLORH #de fine COLOR H class Color - private: 0-255 0-255 0-255 red; green blue; // Amount of red / Amount of green // Amount of blue int int public: Color) // Initializes red, green, and blue to zero void setRed (int rr) I/ Sets red to rr void setGreen (int gg) I Sets green to void setBlue (int bb); Sets blue to bb // Returns red int getRed) const; int getGreen const II Returns green int getBlue) const; I/Returns blue void print) const // Writes to std output cout
Explanation / Answer
Color.cpp
Color::Color(){
red = 0.0;
green = 0.0;
blue = 0.0;
}
void Color::setRed(int rr){
red = rr;
}
void Color::setBlue(int bb){
blue = bb;
}
void Color::setGreen(int gg){
green = gg;
}
int Color::getRed() const{
return red;
}
int Color::getBlue() const{
return blue;
}
int Color::getGreen() const{
return green;
}
Shape.h
#ifndef SHAPE_H_
#define SHAPE_H_
#include "Color.h"
class Shape{
private:
int r;
int h;
int b;
public:
Shape();
Shape(int r,int h,int b);
Color getColor();
double area() const;
double parimeter() const;
};
#endif
triangle.cpp
Shape* s;
Triangle::Triangle(){
a = 0.0;
b = 0.0;
c = 0.0;
s = new Shape();
}
Triangle::Triangle(double aaa,double bbb,double ccc,int rr,int gg,int bb){
a = aaa;
b = bbb;
c = ccc;
s = new Shape(rr,gg,bb);
}
double Triangle::area(){
return 0*5*a*b;
}
double Triangle::perimeter(){
return (a+b+c)/3;
}
rectangle.cpp
Shape* s;
Rectangle::Rectangle(){
l = 0.0;
w = 0.0;
c = 0.0;
s = new Shape();
}
Rectangle::Rectangle(double aa,double bb,int rr,int gg,int bb){
l = aa;
w = bb;
s = new Shape(rr,gg,bb);
}
double Rectangle::area(){
return this.l * this.w;
}
double Rectangle::perimeter(){
return 2*(this.l + this.w);
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.