05_OOa: Testat bestanden
This commit is contained in:
parent
86f07e7b23
commit
72b7ae9a7d
|
@ -27,5 +27,7 @@ add_executable(05_OOa_Testat
|
||||||
Testat/Rectangle.h
|
Testat/Rectangle.h
|
||||||
Testat/Scene.cpp
|
Testat/Scene.cpp
|
||||||
Testat/Scene.h
|
Testat/Scene.h
|
||||||
|
Testat/Sign.cpp
|
||||||
|
Testat/Sign.h
|
||||||
../../helpers/AnsiConsole.cpp
|
../../helpers/AnsiConsole.cpp
|
||||||
)
|
)
|
|
@ -0,0 +1,11 @@
|
||||||
|
#include "Sign.h"
|
||||||
|
|
||||||
|
Sign::Sign(int x, int y, int width, int height, Colors color, std::string _text) :
|
||||||
|
Rectangle::Rectangle(x, y, width, height, color), text(_text) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void Sign::draw() {
|
||||||
|
Rectangle::draw();
|
||||||
|
int x = Rectangle::position.x - (text.length()/2);
|
||||||
|
ansiConsole.printText(x, Rectangle::position.y, text, Rectangle::color);
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
#ifndef C_C_SIGN_H
|
||||||
|
#define C_C_SIGN_H
|
||||||
|
|
||||||
|
#include "Rectangle.h"
|
||||||
|
|
||||||
|
class Sign : public Rectangle {
|
||||||
|
protected:
|
||||||
|
std::string text;
|
||||||
|
public:
|
||||||
|
Sign(int x = 0, int y = 0, int width = 0, int height = 0, Colors color = Colors::WHITE, std::string text = "Hier Text einfügen");
|
||||||
|
void draw() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
|
@ -4,6 +4,7 @@
|
||||||
#include "Circle.h"
|
#include "Circle.h"
|
||||||
#include "Rectangle.h"
|
#include "Rectangle.h"
|
||||||
#include "Scene.h"
|
#include "Scene.h"
|
||||||
|
#include "Sign.h"
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
std::vector<Shape*> shapes;
|
std::vector<Shape*> shapes;
|
||||||
|
@ -17,7 +18,8 @@ int main(int argc, char **argv) {
|
||||||
shapes.push_back(new Circle(30, 20, 15, Colors::GREEN));
|
shapes.push_back(new Circle(30, 20, 15, Colors::GREEN));
|
||||||
|
|
||||||
|
|
||||||
shapes.push_back(new Rectangle(5, 21, 10, 10, Colors::MAGENTA));
|
shapes.push_back(new Rectangle(5, 25, 10, 10, Colors::MAGENTA));
|
||||||
|
shapes.push_back(new Sign(60, 10, 20, 5, Colors::CYAN, "Hallo Welt"));
|
||||||
|
|
||||||
shapes.push_back(new Point(5, 10, Colors::WHITE));
|
shapes.push_back(new Point(5, 10, Colors::WHITE));
|
||||||
shapes.push_back(new Point(15, 7, Colors::WHITE));
|
shapes.push_back(new Point(15, 7, Colors::WHITE));
|
||||||
|
|
Loading…
Reference in New Issue