From 33613a85afc4b1481367fbe92a17ee59c240250b Mon Sep 17 00:00:00 2001 From: Sven Eisenhauer Date: Fri, 10 Nov 2023 15:11:48 +0100 Subject: add new repo --- Bachelor/Prog2/Z-Uebung/Teil1/main1.cpp | 61 +++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 Bachelor/Prog2/Z-Uebung/Teil1/main1.cpp (limited to 'Bachelor/Prog2/Z-Uebung/Teil1/main1.cpp') diff --git a/Bachelor/Prog2/Z-Uebung/Teil1/main1.cpp b/Bachelor/Prog2/Z-Uebung/Teil1/main1.cpp new file mode 100644 index 0000000..3dbd65d --- /dev/null +++ b/Bachelor/Prog2/Z-Uebung/Teil1/main1.cpp @@ -0,0 +1,61 @@ +// Übung PG 2, Teil 1 +// test Shape and Polyline +// Author: Prinz / Kirch-Prinz / Weber +// Date: 26.05.05 + +#include +using std::cout; +using std::endl; +using std::cin; + +#include "shape.h" + +int main() +{ + cout << "\nGeometrische Figuren: Linienzuege\n" << endl; + + Point vertices[] = { Point( -1, 0 ), Point( 0, 2 ), Point( 1, 0 ) }; + + Polyline poly1, + poly2( Point( 1, 2 ), Point( 2, 0 ) ), + poly3( vertices, 3 ), + poly4( poly3 ); // use of copy constructor + + cout << "Die Punkte der vier Linienzuege: \n" + << poly1.toString() << endl + << poly2.toString() << endl + << poly3.toString() << endl + << poly4.toString() << endl; + cin.get(); + + cout << "Zuweisungen testen:" << endl; // test assignment + poly1 = poly4; + cout << poly1.toString() << endl; + poly1 = Polyline(); + cout << poly1.toString() << endl << endl; + + cout << "Punkte anhaengen:" << endl; // append points + poly1 += Point( 0.5, 2.5 ); + cout << poly1.toString() << endl; + poly4 += Point( 2, 2 ); + cout << poly4.toString() << endl; + cout << "Anzahl Linien: " << poly4.getNumberOfLines() << endl + << "Laenge : " << poly4.getLength() << endl; + + cout << "Nach der Skalierung mit dem Faktor 2.0" << endl; + poly4.scale( 2.0 ); + cout << poly4.toString() << endl << endl; + + cout << "Linienzuege anhaengen:" << endl; // append lines + poly2 += poly1; + cout << poly2.toString() << endl; + poly4 += poly3; + cout << poly4.toString() << endl << endl; + + cout << "Linienzug verschieben:" << endl; // displacement + poly4.move( 1,0 ); + cout << poly4.toString() << endl; + cout << "Neuer Anker: " << poly4.getAnchor() << endl; + + return 0; +} -- cgit v1.2.3