Comment + unique_ptr issue + correct horse battery staple
This commit is contained in:
parent
99f1a4863a
commit
764f468028
19 changed files with 222 additions and 220 deletions
|
@ -1,7 +1,7 @@
|
|||
#ifndef COORDINATE_H
|
||||
#define COORDINATE_H
|
||||
class Coordinate {
|
||||
public:
|
||||
public:
|
||||
Coordinate();
|
||||
Coordinate(const double X, const double Y);
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#define EQUILATERAL_TRIANGLE_H
|
||||
#include "Triangle.h"
|
||||
class EquilateralTriangle : public ATriangle {
|
||||
public:
|
||||
public:
|
||||
bool validate() override;
|
||||
};
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ bool double_eq(double first, double second) {
|
|||
}
|
||||
}
|
||||
|
||||
double calculate_distance(Coordinate &firstPoint, Coordinate &secondPoint) {
|
||||
double calculate_distance(Coordinate& firstPoint, Coordinate& secondPoint) {
|
||||
return std::sqrt(std::pow(secondPoint.x - firstPoint.x, 2) +
|
||||
std::pow(secondPoint.y - firstPoint.y, 2));
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ bool double_eq(double first, double second);
|
|||
* @param secondPoint The second coordinate point to compare the first to
|
||||
* @return double The pythagorean distance between the two points
|
||||
*/
|
||||
double calculate_distance(Coordinate &firstPoint, Coordinate &secondPoint);
|
||||
double calculate_distance(Coordinate& firstPoint, Coordinate& secondPoint);
|
||||
|
||||
/**
|
||||
* @brief Returns true if all of the side lengths in the specified array make a
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#define ISOSCELES_TRIANGLE_H
|
||||
#include "Triangle.h"
|
||||
class IsoscelesTriangle : public ATriangle {
|
||||
public:
|
||||
public:
|
||||
bool validate() override;
|
||||
};
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ APolygon::~APolygon() { delete[] mVertices; }
|
|||
|
||||
void APolygon::setColor(const sf::Color COLOR) { _color = COLOR; }
|
||||
|
||||
void APolygon::draw(sf::RenderTarget &window) {
|
||||
void APolygon::draw(sf::RenderTarget& window) {
|
||||
sf::ConvexShape shape(mNumVertices);
|
||||
for (int i = 0; i < mNumVertices; i++) {
|
||||
shape.setPoint(i, sf::Vector2f(mVertices[i].x, mVertices[i].y));
|
||||
|
|
10
Polygon.h
10
Polygon.h
|
@ -5,7 +5,7 @@
|
|||
#include <SFML/Graphics.hpp>
|
||||
|
||||
class APolygon {
|
||||
public:
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a new Polygon object, with a white color and 0 vertices
|
||||
*/
|
||||
|
@ -26,7 +26,7 @@ class APolygon {
|
|||
*
|
||||
* @param window The render target to draw the polygon on
|
||||
*/
|
||||
void draw(sf::RenderTarget &window);
|
||||
void draw(sf::RenderTarget& window);
|
||||
/**
|
||||
* @brief Sets the coordinate point at a specific vertex of this polygon
|
||||
*
|
||||
|
@ -43,11 +43,11 @@ class APolygon {
|
|||
*/
|
||||
virtual bool validate() = 0;
|
||||
|
||||
protected:
|
||||
protected:
|
||||
short mNumVertices;
|
||||
Coordinate *mVertices;
|
||||
Coordinate* mVertices;
|
||||
|
||||
private:
|
||||
private:
|
||||
sf::Color _color;
|
||||
};
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#define QUADRILATERAL_H
|
||||
#include "Polygon.h"
|
||||
class AQuadrilateral : public APolygon {
|
||||
public:
|
||||
public:
|
||||
AQuadrilateral();
|
||||
};
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#define RHOMBUS_H
|
||||
#include "Quadrilateral.h"
|
||||
class Rhombus : public AQuadrilateral {
|
||||
public:
|
||||
public:
|
||||
bool validate() override;
|
||||
};
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#define SCALENE_TRIANGLE_H
|
||||
#include "Triangle.h"
|
||||
class ScaleneTriangle : public ATriangle {
|
||||
public:
|
||||
public:
|
||||
bool validate() override;
|
||||
};
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#define TRIANGLE_H
|
||||
#include "Polygon.h"
|
||||
class ATriangle : public APolygon {
|
||||
public:
|
||||
public:
|
||||
ATriangle();
|
||||
};
|
||||
|
||||
|
|
22
main.cpp
22
main.cpp
|
@ -1,8 +1,10 @@
|
|||
/**
|
||||
* @author Tyler Beckman (tyler_beckman@mines.edu)
|
||||
* @brief A program template for CSCI200
|
||||
* @brief A program to read polygon points and colors from a data file and
|
||||
* display them utilizing the SFML library, validating all shapes at each point
|
||||
* during processing.
|
||||
* @version 1
|
||||
* @date 2024-09-21
|
||||
* @date 2024-11-11
|
||||
*/
|
||||
|
||||
#include "Coordinate.h"
|
||||
|
@ -64,10 +66,10 @@ int main(void) {
|
|||
currentPolygon = std::make_unique<Rhombus>();
|
||||
break;
|
||||
default:
|
||||
std::cout << "polygon is invalid - \"" << type << " " << x1
|
||||
<< " " << y1 << " " << x2 << " " << y2 << " " << x3
|
||||
<< " " << y3 << " " << x4 << " " << y4 << " " << r
|
||||
<< " " << g << " " << b << "\"" << std::endl;
|
||||
std::cout << "polygon is invalid - \"" << type << " " << x1 << " " << y1
|
||||
<< " " << x2 << " " << y2 << " " << x3 << " " << y3 << " "
|
||||
<< x4 << " " << y4 << " " << r << " " << g << " " << b << "\""
|
||||
<< std::endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -80,20 +82,20 @@ int main(void) {
|
|||
currentPolygon->setColor(sf::Color(r, g, b));
|
||||
|
||||
if (!currentPolygon->validate()) {
|
||||
std::cout << "polygon is invalid - \"" << type << " " << x1 << " "
|
||||
<< y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3;
|
||||
std::cout << "polygon is invalid - \"" << type << " " << x1 << " " << y1
|
||||
<< " " << x2 << " " << y2 << " " << x3 << " " << y3;
|
||||
if (x4 != -1) {
|
||||
std::cout << " " << x4 << " " << y4;
|
||||
}
|
||||
std::cout << " " << r << " " << g << " " << b << "\"" << std::endl;
|
||||
} else {
|
||||
polygonList.push_back(currentPolygon);
|
||||
polygonList.push_back(std::move(currentPolygon));
|
||||
}
|
||||
};
|
||||
|
||||
// Start SFML Rendering logic
|
||||
sf::RenderWindow window(
|
||||
sf::VideoMode(640, 640), ":3",
|
||||
sf::VideoMode(640, 640), "correct horse battery staple",
|
||||
sf::Style::Titlebar | sf::Style::Close // Disable window resize
|
||||
);
|
||||
window.setVerticalSyncEnabled(true);
|
||||
|
|
Loading…
Reference in a new issue