Summary Files Commits Branches @commit @diff @stats
path: root / Year 1 / Object-oriented Programming / 12-Practice-17.05.2022 / ex2
diff options
context:
space:
mode:
Commitff171c3bc508e4a82e2329c550532f60a8be2e38 (patch)
Author
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-05-17 21:14:55 +0300
Committer
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-05-17 21:14:55 +0300
Files0d6542c85b32a0b439fc540735214e5a8264c051 /Year 1/Object-oriented Programming/12-Practice-17.05.2022/ex2
uni-projects-ff171c3bc508e4a82e2329c550532f60a8be2e38.tar
uni-projects-ff171c3bc508e4a82e2329c550532f60a8be2e38.tar.gz
uni-projects-ff171c3bc508e4a82e2329c550532f60a8be2e38.zip
Parent2a8bf5b484ae5eb05bbaaeaf613089dc4a15f73a (diff)
Added work from today's practice
diff --git a/Year 1/Object-oriented Programming/12-Practice-17.05.2022/ex2/Penguin.h b/Year 1/Object-oriented Programming/12-Practice-17.05.2022/ex2/Penguin.h
new file mode 100644
index 0000000..8546670
--- /dev/null
+++ b/Year 1/Object-oriented Programming/12-Practice-17.05.2022/ex2/Penguin.h
@@ -0,0 +1,9 @@
+#include "Prize.h"
+
+class Penguin : public Prize {
+public:
+ Penguin(unsigned price, unsigned points) : Prize(price, points) {}
+ void vizualize() const {
+ print("viz/penguin.txt");
+ }
+};
diff --git a/Year 1/Object-oriented Programming/12-Practice-17.05.2022/ex2/Prize.h b/Year 1/Object-oriented Programming/12-Practice-17.05.2022/ex2/Prize.h
new file mode 100644
index 0000000..6b68613
--- /dev/null
+++ b/Year 1/Object-oriented Programming/12-Practice-17.05.2022/ex2/Prize.h
@@ -0,0 +1,30 @@
+#include <fstream>
+#include <iostream>
+
+class Prize {
+protected:
+ unsigned money;
+ unsigned points;
+
+public:
+ Prize(unsigned price, unsigned points) {
+ this->money = price;
+ this->points = points;
+ }
+ virtual void vizualize() const = 0;
+};
+
+
+void print(const char* fileName) {
+ std::ifstream file(fileName);
+ if (!file.is_open()) return;
+
+ char buffer[1024];
+ while (!file.eof()) {
+ file.read(buffer, 1024);
+ std::cout << buffer;
+ }
+ std::cout << std::endl;
+ file.close();
+}
+
diff --git a/Year 1/Object-oriented Programming/12-Practice-17.05.2022/ex2/main.cpp b/Year 1/Object-oriented Programming/12-Practice-17.05.2022/ex2/main.cpp
new file mode 100644
index 0000000..0bdbe73
--- /dev/null
+++ b/Year 1/Object-oriented Programming/12-Practice-17.05.2022/ex2/main.cpp
@@ -0,0 +1,6 @@
+#include "Penguin.h"
+
+int main() {
+ Penguin penguinPrize(15, 64);
+ penguinPrize.vizualize();
+}
diff --git a/Year 1/Object-oriented Programming/12-Practice-17.05.2022/ex2/viz/pacman.txt b/Year 1/Object-oriented Programming/12-Practice-17.05.2022/ex2/viz/pacman.txt
new file mode 100644
index 0000000..72b1027
--- /dev/null
+++ b/Year 1/Object-oriented Programming/12-Practice-17.05.2022/ex2/viz/pacman.txt
@@ -0,0 +1,11 @@
+================================================.
+ .-. .-. .--. |
+ | OO| | OO| / _.-' .-. .-. .-. .''. |
+ | | | | \ '-. '-' '-' '-' '..' |
+ '^^^' '^^^' '--' |
+===============. .-. .================. .-. |
+ | | | | | '-' |
+ | | | | | |
+ | ':-:' | | .-. |
+l42 | '-' | | '-' |
+===============' '================' | \ No newline at end of file
diff --git a/Year 1/Object-oriented Programming/12-Practice-17.05.2022/ex2/viz/penguin.txt b/Year 1/Object-oriented Programming/12-Practice-17.05.2022/ex2/viz/penguin.txt
new file mode 100644
index 0000000..f734113
--- /dev/null
+++ b/Year 1/Object-oriented Programming/12-Practice-17.05.2022/ex2/viz/penguin.txt
@@ -0,0 +1,16 @@
+ _nnnn_
+ dGGGGMMb
+ @p~qp~~qMb
+ M|@||@) M|
+ @,----.JM|
+ JS^\__/ qKL
+ dZP qKRb
+ dZP qKKb
+ fZP SMMb
+ HZM MMMM
+ FqM MMMM
+ __| ". |\dS"qML
+ | `. | `' \Zq
+_) \.___.,| .'
+\____ )MMMMMP| .'
+ `-' `--' hjm \ No newline at end of file