#circle ++

19 messages · Page 1 of 1 (latest)

modern domeBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

brazen tundra
#
//
// Created by ayubz on 5/6/2023.
//

#include "Point.h"

Point::Point(){
    x = 0;
    y = 0;
}

Point::Point(int x, int y) {
    this->x = x;
    this->y = y;
}

int Point::getX() {
    return x;
}
int Point::getY(){
    return y;
}

void Point::setX(int x){
    if (x >= 0) {
        this->x = x;
    }
}

void Point::setY(int y){
    if (y >= 0) {
        this->y = y;
    }
}```
#

point.cpp

#
//
// Created by ayubz on 5/6/2023.
//

#ifndef ZAZIAYUBHW10_POINT_H
#define ZAZIAYUBHW10_POINT_H


using namespace std;

class Point {

public:
    Point();
    Point(int x, int y);
    int getX();
    int getY();
    void setX(int x);
    void setY(int y);
private:
    int x;
    int y;

};




#endif //ZAZIAYUBHW10_POINT_H
#

point.h

#
//
// Created by ayubz on 5/6/2023.
//

#include "Circle.h"
#include <iostream>

using namespace std;

Circle::Circle(){
    radius = 0;
}

Circle::Circle(double radius){
    this->radius = radius;
}

double Circle::getRadius(){
    return radius;
}

void Circle::setRadius(double radius){
    if (radius >= 0){
        this->radius = radius;
    }
}

void Circle::erase(){
    cout << "This is the Circle class: ";
    cout << "Erasing the Circle object" << endl;
}

void Circle::draw(){
    cout << "This is the Circle class: ";
    cout << "Drawing the Circle object" << endl;
}```
#

circle.cpp

#
//
// Created by ayubz on 5/6/2023.
//

#ifndef ZAZIAYUBHW10_CIRCLE_H
#define ZAZIAYUBHW10_CIRCLE_H

#include <string>
#include "Shape.h"

using namespace std;

class Circle : public Shape {
public:
    Circle();
    Circle(double radius);
    double getRadius();
    void setRadius(double radius);
    void erase();
    void draw();
private:
    double radius;
};


#endif //ZAZIAYUBHW10_CIRCLE_H
#

circle.h

#
//
// Created by ayubz on 5/6/2023.
//

#include "Rectangle.h"
#include <iostream>

using namespace std;

Rectangle::Rectangle(){
    length = 0;
    width = 0;
}

Rectangle::Rectangle(double length, double width){
    this->length = length;
    this->width = width;
}

double Rectangle::getLength(){
    return length;
}

double Rectangle::getWidth(){
    return width;
}

void Rectangle::setLength(double length){
    if (length >= 0){
        this->length = length;
    }
}

void Rectangle::setWidth(double width){
    if (width >= 0){
        this->width = width;
    }
}

void Rectangle::erase(){
    cout << "This is the Rectangle Class: ";
    cout << "Erasing the Rectangle object" << endl;
}

void Rectangle::draw(){
    cout << "This is the Rectangle class: ";
    cout << "Drawing the Rectangle object" << endl;
}``` rectangle.cpp
#
//
// Created by ayubz on 5/6/2023.
//

#ifndef ZAZIAYUBHW10_RECTANGLE_H
#define ZAZIAYUBHW10_RECTANGLE_H


#include <string>
#include "Shape.h"

using namespace std;

class Rectangle : public Shape {
public:
    Rectangle();
    Rectangle(double length, double width);
    double getLength();
    double getWidth();
    void setLength(double length);
    void setWidth(double width);
    void erase();
    void draw();
private:
    double length;
    double width;
};






#endif //ZAZIAYUBHW10_RECTANGLE_H
#

rectangle.h

#
//
// Created by ayubz on 5/6/2023.
//

#include "Shape.h"
#include <iostream>

using namespace std;

Shape::Shape(){
    location = Point(0, 0);
    fillColor = "No color set";
}

Shape::Shape(Point location, string fillColor){
    this->location = location;
    this->fillColor = fillColor;
}

Point Shape::getLocation(){
    return location;
}

string Shape::getFillColor(){
    return fillColor;
}

void Shape::setLocation(Point location){
    this->location = location;
}

void Shape::setFillColor(string fillColor){
    this->fillColor = fillColor;
}

void Shape::move(double deltaX, double deltaY){
    this->location = Point(deltaX, deltaY);
    erase();
    draw();
}

void Shape::erase() {
    cout << "This is the Shape class: ";
    cout << "Erasing the shape object" << endl;
}

void Shape::draw(){
    cout << "This is the Shape Class: ";
    cout << "Drawing the shape object" << endl;
}```
#

shape.cpp

#
#define ZAZIAYUBHW10_SHAPE_H

#include <string>
#include "Point.h"

using namespace std;

class Shape {
public:
    Shape();
    Shape(Point location, string fillColor);
    Point getLocation();
    string getFillColor();
    void setLocation(Point location);
    void setFillColor(string fillColor);
    void move(double deltaX, double deltaY);
    virtual void erase();
    virtual void draw();
private:
    Point location;
    string fillColor;
};


#endif //ZAZIAYUBHW10_SHAPE_H
#

shape.h

spiral raptor
#

Which file are the errors coming from?

#

(For other people just looking in)

#

?