229 lines
7.3 KiB
Plaintext
229 lines
7.3 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"attachments": {},
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Aufgabe 1: Ein eigenes kleines C++-Programm (*new*/*delete*/*abstract base class*) (1 Punkt)"
|
|
]
|
|
},
|
|
{
|
|
"attachments": {},
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Erstellen Sie in [`task1.main.cpp`](task1.main.cpp) ein lauffähiges Ein-Dateien-Programm das folgende Struktur aufweist:\n",
|
|
"\n",
|
|
"- Einbinden benötigter Header-Dateien aus der Standardbibliothek, z.B.:\n",
|
|
"\t```cpp\n",
|
|
"\t#include <iostream> // std::cout, std::endl\n",
|
|
"\t#include <vector> // std::vector\n",
|
|
"\t...\n",
|
|
"\t```\n",
|
|
"- Einbinden einer bestehenden Klassenhierarchie \n",
|
|
"\t```cpp\n",
|
|
"\t#include \"task1.hierarchy.hpp\"\n",
|
|
"\t``` \n",
|
|
"- Definition/Implementierung einer `main`-Funktion, die mit dynamische allozierte Instanzen der Klassen aus der Klassenhierarchie arbeitet , z.B.:\n",
|
|
"\t```cpp\n",
|
|
"\tint main(){\n",
|
|
"\n",
|
|
"\t auto ptr = new Circle(5);\t\t\n",
|
|
"\t ...\n",
|
|
"\n",
|
|
"\t std::cout << ptr->area() << std::endl;\n",
|
|
"\n",
|
|
"\t delete ptr;\n",
|
|
"\n",
|
|
"\t return 0;\n",
|
|
"\t}\n",
|
|
"\t``` \n"
|
|
]
|
|
},
|
|
{
|
|
"attachments": {},
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"- Eine genaue Beschreibung und Anforderungen finden Sie in [`task1.main.cpp`](task1.main.cpp)\n",
|
|
"- Ihre Implementierung erfolgt ebenfalls in [`task1.main.cpp`](task1.main.cpp)"
|
|
]
|
|
},
|
|
{
|
|
"attachments": {},
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Aufgabe 2: Erweitern einer gegebenen Klassenhierarchie (Implementierung weiterer abgeleiteter Klassen) (1 Punkt)"
|
|
]
|
|
},
|
|
{
|
|
"attachments": {},
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Es ist eine abstrakten Schnittstellenklasse für die Serialisierung eines XML-Elements `task2::Element` gegeben.\n",
|
|
"Ebenso ist als Beispiel die Implementierung `task2::LineElement` gegeben, die diese Schnittstelle implementiert.\n",
|
|
"\n",
|
|
"Sie sollen zwei weitere Implementierung der Schnittstelle `task2::PolylineElement` und `task2::CircleElement` analog zu `task2::LineElement` implementieren.\n"
|
|
]
|
|
},
|
|
{
|
|
"attachments": {},
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Implementieren Sie die folgende freie Funktionen:\n",
|
|
"\n",
|
|
"```cpp\n",
|
|
"namespace task2 {\n",
|
|
"\n",
|
|
"struct Element {\n",
|
|
" virtual std::string open() const = 0; ///< returns the opening or self-closing tag of an XML element\n",
|
|
" virtual std::string text() const = 0; ///< returns the content tag of an XML element\n",
|
|
" virtual std::string close() const = 0; ///< returns the closing tag of an XML element\n",
|
|
"};\n",
|
|
"\n",
|
|
"struct LineElement : Element; // provided\n",
|
|
"struct PolylineElement : Element; // todo\n",
|
|
"struct CircleElement : Element; // todo\n",
|
|
"\n",
|
|
"```"
|
|
]
|
|
},
|
|
{
|
|
"attachments": {},
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"- Eine genaue Beschreibung der Schnittstellenklasse finden Sie in [`task2.Element.hpp`](task2.Element.hpp)\n",
|
|
"- Das vorgegebene Beispiel finden Sie in [`task2.Line.hpp`](task2.Line.hpp)\n",
|
|
"- Ihre Implementierung erfolgt in [`task2.Polyline.hpp`](task2.Polyline.hpp) und [`task2.Circle.hpp`](task2.Circle.hpp)\n",
|
|
"- Die zugeordneten Tests finden Sie in [`task2.test.cpp`](task2.test.cpp)"
|
|
]
|
|
},
|
|
{
|
|
"attachments": {},
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Aufgabe 3: Arbeiten mit einer gegebenen Klasse, die dynamisch allozierte Resourcen verwaltet, und an die dynamisch allozierte Resourcen übergeben werden (1 Punkt)\n",
|
|
"\n",
|
|
"Sie implementieren eine Funktion, die mittels ein SVG-Bild erzeugt und abspeichert:\n",
|
|
"\n",
|
|
"```cpp\n",
|
|
"task2::BBox plot_image(std::filesystem::path filepath, \n",
|
|
" const std::vector<task2::Line>& lines, \n",
|
|
" const std::vector<task2::Polyline>& polylines,\n",
|
|
" const std::vector<task2::Circle>& circles);\n",
|
|
"```\n",
|
|
"\n",
|
|
"Zur Implementierung dieser kommt die Klasse `task3::Image` zum Einsatz. Die Schnittstellen dieser Klasse basieren auf `task2::Element`.\n",
|
|
"\n",
|
|
"```cpp\n",
|
|
"namespace task3 {\n",
|
|
"\n",
|
|
"class Image {\n",
|
|
"public:\n",
|
|
" Image(Element* root) : root(root), elements() {}\n",
|
|
" void add(Element* elem) { elements.push_back(elem); }\n",
|
|
" void save(std::filesystem::path filepath) const;\n",
|
|
" ~Image();\n",
|
|
"private:\n",
|
|
" Element* root; \n",
|
|
" std::vector<Element*> elements;\n",
|
|
"};\n",
|
|
"\n",
|
|
"}\n",
|
|
"```"
|
|
]
|
|
},
|
|
{
|
|
"attachments": {},
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"- Die vorgegebenen Deklaration und eine genaue Beschreibung und Anforderungen finden Sie in [`task3.hpp`](task3.hpp)\n",
|
|
"- Ihre Implementierung erfolgt in [`task3.cpp`](task3.cpp)\n",
|
|
"- Die zugeordneten Tests finden Sie in [`task3.test.cpp`](task3.test.cpp)\n",
|
|
"- In [`task3.Image.hpp`](task3.Image.hpp) finden Sie die vorgegebene Implementierung für `task3::Image`\n",
|
|
"\n",
|
|
"- Optional (für Interessierte): In [`task3.ImageUP.hpp`](task3.ImageUP.hpp) finden Sie eine alternative Implementierung `task3::ImageUP` die mit `std::unique_ptr` arbeitet.\n"
|
|
]
|
|
},
|
|
{
|
|
"attachments": {},
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Unter Voraussetzung einer erfolgreicher Implementierung von Aufgabe 2 erzeugt der Test in Aufgabe 3 folgende Ausgabe:\n",
|
|
"\n",
|
|
""
|
|
]
|
|
},
|
|
{
|
|
"attachments": {},
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Kompilieren/Testen\n",
|
|
"\n",
|
|
"So testen Sie Ihre Implementierung (direkter Aufruf von `g++` und `python`):\n",
|
|
"\n",
|
|
"```shell\n",
|
|
"# prepare\n",
|
|
"mkdir build\n",
|
|
"# compile\n",
|
|
"g++ -g -std=c++20 task1.main.cpp -o build/task1\n",
|
|
"g++ -g -Imodules -std=c++20 task2.test.cpp -o build/task2\n",
|
|
"g++ -g -Imodules -std=c++20 task3.cpp task3.test.cpp -o build/task3\n",
|
|
"\n",
|
|
"# run tests\n",
|
|
"./build/task1\n",
|
|
"./build/task2\n",
|
|
"./build/task3\n",
|
|
"```\n",
|
|
"\n",
|
|
"Alternativ (mittels CMake-Configuration):s\n",
|
|
"\n",
|
|
"```shell\n",
|
|
"# prepare\n",
|
|
"cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug\n",
|
|
"# compile\n",
|
|
"cmake --build build --config Debug --target task1\n",
|
|
"cmake --build build --config Debug --target task2\n",
|
|
"cmake --build build --config Debug --target task3\n",
|
|
"cmake --build build --config Debug # all\n",
|
|
"# run tests\n",
|
|
"ctest --test-dir build -C Debug -R task1 \n",
|
|
"ctest --test-dir build -C Debug -R task2 \n",
|
|
"ctest --test-dir build -C Debug -R task3 \n",
|
|
"ctest --test-dir build -C Debug # all\n",
|
|
"``` \n"
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": ".venv",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.6.15"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 2
|
|
}
|