aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSyndamia <kamen@syndamia.com>2024-04-04 20:11:12 +0300
committerSyndamia <kamen@syndamia.com>2024-04-04 20:11:12 +0300
commita2e284b0056075e2365deaa2455be567c3b3c945 (patch)
tree8a842d1f2ffb9f00989b39d2ab7a7ade1a858d81
parent44d085f265583f0e3cbef294bbe2c8e300aaa452 (diff)
downloadoop-2023-solutions-a2e284b0056075e2365deaa2455be567c3b3c945.tar
oop-2023-solutions-a2e284b0056075e2365deaa2455be567c3b3c945.tar.gz
oop-2023-solutions-a2e284b0056075e2365deaa2455be567c3b3c945.zip
[w7] Added exercise descriptions and solutions
-rw-r--r--week07/Exercise1.cpp87
-rw-r--r--week07/Exercise1.h25
-rw-r--r--week07/Exercise2.cpp24
-rw-r--r--week07/Exercise3.cpp77
-rw-r--r--week07/Exercise3.h15
-rw-r--r--week07/Exercise4.cpp139
-rw-r--r--week07/Exercise4.h24
-rw-r--r--week07/Exercise5.cpp180
-rw-r--r--week07/Exercise5.h26
-rw-r--r--week07/Exercise6.cpp83
-rw-r--r--week07/Exercise6.h27
-rw-r--r--week07/README.md71
12 files changed, 778 insertions, 0 deletions
diff --git a/week07/Exercise1.cpp b/week07/Exercise1.cpp
new file mode 100644
index 0000000..ec2a47a
--- /dev/null
+++ b/week07/Exercise1.cpp
@@ -0,0 +1,87 @@
+#include "Exercise1.h"
+#include <cstring>
+
+/* Private */
+
+void Recipe::resize() {
+ allocated *= 2;
+ Ingredient* moreIngredients = new Ingredient[allocated];
+ for (int i = 0; i < lastIndex; i++) {
+ moreIngredients[i] = ingredients[i];
+ }
+ delete[] ingredients;
+ ingredients = moreIngredients;
+}
+
+void Recipe::free() {
+ delete[] ingredients;
+}
+void Recipe::copyFrom(const Recipe& other) {
+ this->lastIndex = other.lastIndex;
+ this->allocated = other.allocated;
+ this->ingredients = new Ingredient[allocated];
+ for (int i = 0; i < lastIndex; i++) {
+ this->ingredients[i] = other.ingredients[i];
+ }
+}
+
+/* Public */
+
+Recipe::Recipe() {
+ ingredients = nullptr;
+ lastIndex = allocated = 0;
+}
+Recipe::~Recipe() {
+ free();
+}
+Recipe::Recipe(const Recipe& other) {
+ copyFrom(other);
+}
+Recipe& Recipe::operator=(const Recipe& other) {
+ if (this != &other) {
+ free();
+ copyFrom(other);
+ }
+ return *this;
+}
+Recipe::Recipe(Recipe&& other) {
+ this->ingredients = other.ingredients;
+ this->lastIndex = other.lastIndex;
+ this->allocated = other.allocated;
+
+ other.ingredients = nullptr;
+}
+Recipe& Recipe::operator=(Recipe&& other) {
+ if (this != &other) {
+ free();
+
+ this->ingredients = other.ingredients;
+ this->lastIndex = other.lastIndex;
+ this->allocated = other.allocated;
+
+ other.ingredients = nullptr;
+ }
+ return *this;
+}
+
+void Recipe::AddIngredient(const Ingredient& newIng) {
+ if (lastIndex == allocated) {
+ resize();
+ }
+ ingredients[lastIndex++] = newIng;
+}
+void Recipe::RemoveIngredient(const char* name) {
+ int index = 0;
+ while (index < lastIndex && strcmp(ingredients[index].name, name) != 0) {
+ index++;
+ }
+ if (index == lastIndex) {
+ return;
+ }
+
+ while (index < lastIndex) {
+ ingredients[index] = ingredients[index+1];
+ index++;
+ }
+ lastIndex--;
+}
diff --git a/week07/Exercise1.h b/week07/Exercise1.h
new file mode 100644
index 0000000..6de1a09
--- /dev/null
+++ b/week07/Exercise1.h
@@ -0,0 +1,25 @@
+struct Ingredient {
+ char name[512];
+ float amount;
+};
+
+class Recipe {
+ Ingredient* ingredients;
+ unsigned lastIndex;
+ unsigned allocated;
+
+ void resize();
+ void free();
+ void copyFrom(const Recipe& other);
+
+public:
+ Recipe();
+ ~Recipe();
+ Recipe(const Recipe& other);
+ Recipe& operator=(const Recipe& other);
+ Recipe(Recipe&& other);
+ Recipe& operator=(Recipe&& other);
+
+ void AddIngredient(const Ingredient& newIng);
+ void RemoveIngredient(const char* name);
+};
diff --git a/week07/Exercise2.cpp b/week07/Exercise2.cpp
new file mode 100644
index 0000000..2ec31d5
--- /dev/null
+++ b/week07/Exercise2.cpp
@@ -0,0 +1,24 @@
+#include <fstream>
+#include <iostream>
+
+int main() {
+ char fileName[1024];
+ std::cin.getline(fileName, 1024);
+
+ std::ifstream file(fileName);
+ if (!file.is_open()) {
+ std::cout << "Couldn't open file!" << std::endl;
+ return -1;
+ }
+
+ file.seekg(0, std::ios::end);
+ int third = file.tellg() / 3;
+ file.seekg(2 * third - 1, std::ios::beg);
+
+ while (third <= file.tellg()) {
+ std::cout << (char)file.peek();
+ file.seekg(-1, std::ios::cur);
+ }
+
+ file.close();
+}
diff --git a/week07/Exercise3.cpp b/week07/Exercise3.cpp
new file mode 100644
index 0000000..3137ddd
--- /dev/null
+++ b/week07/Exercise3.cpp
@@ -0,0 +1,77 @@
+#include "Exercise3.h"
+#include <fstream>
+#include <iostream>
+
+/* Public */
+
+Thermometer::Thermometer(unsigned maxMeasurable, unsigned minMeasurable, unsigned currentTemperature) {
+ this->maxMeasurable = maxMeasurable;
+ this->minMeasurable = minMeasurable;
+ this->currentTemperature = currentTemperature;
+}
+
+void Thermometer::Print() {
+ std::cout << maxMeasurable << " " << minMeasurable << " " << currentTemperature << std::endl;
+}
+
+void Thermometer::SaveText(const char* fileName) {
+ std::ofstream outFile(fileName);
+ if (!outFile.is_open()) {
+ return;
+ }
+
+ outFile << maxMeasurable << "," << minMeasurable << "," << currentTemperature;
+ outFile.close();
+}
+void Thermometer::LoadText(const char* fileName) {
+ std::ifstream inFile(fileName);
+ if (!inFile.is_open()) {
+ return;
+ }
+
+ inFile >> maxMeasurable;
+ inFile.ignore();
+ inFile >> minMeasurable;
+ inFile.ignore();
+ inFile >> currentTemperature;
+ inFile.close();
+}
+
+void Thermometer::SaveBinary(const char* fileName) {
+ std::ofstream outFile(fileName, std::ios::binary);
+ if (!outFile.is_open()) {
+ return;
+ }
+
+ outFile.write((const char*)&maxMeasurable, sizeof(maxMeasurable));
+ outFile.write((const char*)&minMeasurable, sizeof(minMeasurable));
+ outFile.write((const char*)&currentTemperature, sizeof(currentTemperature));
+ outFile.close();
+}
+void Thermometer::LoadBinary(const char* fileName) {
+ std::ifstream inFile(fileName, std::ios::binary);
+ if (!inFile.is_open()) {
+ return;
+ }
+
+ inFile.read((char*)&maxMeasurable, sizeof(maxMeasurable));
+ inFile.read((char*)&minMeasurable, sizeof(minMeasurable));
+ inFile.read((char*)&currentTemperature, sizeof(currentTemperature));
+ inFile.close();
+}
+
+int main() {
+ Thermometer t1(100, 0, 20);
+ t1.SaveText("t1.txt");
+
+ Thermometer t2(50, 20, 36);
+ t2.SaveBinary("t2.dat");
+
+ Thermometer t3(5, 5, 5);
+
+ t3.LoadText("t1.txt");
+ t3.Print();
+
+ t3.LoadBinary("t2.dat");
+ t3.Print();
+}
diff --git a/week07/Exercise3.h b/week07/Exercise3.h
new file mode 100644
index 0000000..2cf27bf
--- /dev/null
+++ b/week07/Exercise3.h
@@ -0,0 +1,15 @@
+class Thermometer {
+ unsigned maxMeasurable;
+ unsigned minMeasurable;
+ unsigned currentTemperature;
+
+public:
+ Thermometer(unsigned maxMeasurable, unsigned minMeasurable, unsigned currentTemperature);
+ void Print();
+
+ void SaveText(const char* fileName);
+ void LoadText(const char* fileName);
+
+ void SaveBinary(const char* fileName);
+ void LoadBinary(const char* fileName);
+};
diff --git a/week07/Exercise4.cpp b/week07/Exercise4.cpp
new file mode 100644
index 0000000..50eb587
--- /dev/null
+++ b/week07/Exercise4.cpp
@@ -0,0 +1,139 @@
+#include "Exercise4.h"
+#include <fstream>
+#include <iostream>
+#include <cstring>
+
+/* Private */
+
+void Street::free() {
+ delete[] name;
+}
+void Street::copyFrom(const Street& other) {
+ this->number = other.number;
+ this->name = new char[strlen(other.name)+1];
+ strcpy(this->name, other.name);
+}
+
+/* Public */
+
+Street::Street(const char* name, int number) {
+ this->number = number;
+ this->name = new char[strlen(name)+1];
+ strcpy(this->name, name);
+}
+
+void Street::Print() {
+ std::cout << name << " " << number << std::endl;
+}
+
+Street::Street() {
+ this->name = nullptr;
+ this->number = 0;
+}
+Street::~Street() {
+ free();
+}
+Street::Street(const Street& other) {
+ copyFrom(other);
+}
+Street& Street::operator=(const Street& other) {
+ if (this != &other) {
+ free();
+ copyFrom(other);
+ }
+ return *this;
+}
+Street::Street(Street&& other) {
+ this->name = other.name;
+ this->number = other.number;
+
+ other.name = nullptr;
+}
+Street& Street::operator=(Street&& other) {
+ if (this != &other) {
+ free();
+
+ this->name = other.name;
+ this->number = other.number;
+
+ other.name = nullptr;
+ }
+ return *this;
+}
+
+void Street::SaveText(const char* fileName) {
+ std::ofstream outFile(fileName);
+ if (!outFile.is_open()) {
+ return;
+ }
+
+ outFile << number << ',' << name;
+ outFile.close();
+}
+void Street::LoadText(const char* fileName) {
+ std::ifstream inFile(fileName);
+ if (!inFile.is_open()) {
+ return;
+ }
+
+ free();
+
+ inFile >> number;
+ inFile.ignore();
+
+ unsigned nameStart = inFile.tellg();
+ inFile.seekg(0, std::ios::end);
+ unsigned nameLen = (unsigned)inFile.tellg() - nameStart + 1;
+ inFile.seekg(nameStart, std::ios::beg);
+
+ name = new char[nameLen+1];
+ inFile.get(name, nameLen);
+ name[nameLen] = '\0';
+
+ inFile.close();
+}
+
+void Street::SaveBinary(const char* fileName) {
+ std::ofstream outFile(fileName, std::ios::binary);
+ if (!outFile.is_open()) {
+ return;
+ }
+
+ outFile.write((const char*)&number, sizeof(number));
+ outFile.write(name, sizeof(char) * (strlen(name)+1));
+
+ outFile.close();
+}
+void Street::LoadBinary(const char* fileName) {
+ std::ifstream inFile(fileName, std::ios::binary);
+ if (!inFile.is_open()) {
+ return;
+ }
+
+ inFile.seekg(0, std::ios::end);
+ unsigned nameLen = (unsigned)inFile.tellg() - sizeof(number);
+ inFile.seekg(0, std::ios::beg);
+
+ free();
+
+ inFile.read((char*)&number, sizeof(number));
+ name = new char[nameLen];
+ inFile.read(name, nameLen);
+
+ inFile.close();
+}
+
+int main() {
+ Street s1("Hollywood Blvd", 13);
+ s1.SaveText("s1.txt");
+
+ Street s2("Djeims Baucher", 5);
+ s2.SaveBinary("s2.dat");
+
+ Street s3;
+ s3.LoadText("s1.txt");
+ s3.Print();
+
+ s3.LoadBinary("s2.dat");
+ s3.Print();
+}
diff --git a/week07/Exercise4.h b/week07/Exercise4.h
new file mode 100644
index 0000000..c5dc5c9
--- /dev/null
+++ b/week07/Exercise4.h
@@ -0,0 +1,24 @@
+class Street {
+ char* name;
+ int number;
+
+ void free();
+ void copyFrom(const Street& other);
+
+public:
+ Street(const char* name, int number);
+ void Print();
+
+ Street();
+ ~Street();
+ Street(const Street& other);
+ Street& operator=(const Street& other);
+ Street(Street&& other);
+ Street& operator=(Street&& other);
+
+ void SaveText(const char* fileName);
+ void LoadText(const char* fileName);
+
+ void SaveBinary(const char* fileName);
+ void LoadBinary(const char* fileName);
+};
diff --git a/week07/Exercise5.cpp b/week07/Exercise5.cpp
new file mode 100644
index 0000000..8187771
--- /dev/null
+++ b/week07/Exercise5.cpp
@@ -0,0 +1,180 @@
+#include "Exercise5.h"
+#include <fstream>
+#include <iostream>
+#include <cstring>
+
+/* Private */
+
+void TransportTicket::free() {
+ delete[] source;
+ delete[] destination;
+}
+void TransportTicket::copyFrom(const TransportTicket& other) {
+ this->id = other.id;
+ this->source = new char[strlen(other.source)+1];
+ strcpy(this->source, other.source);
+ this->destination = new char[strlen(other.destination)+1];
+ strcpy(this->destination, other.destination);
+ this->price = other.price;
+}
+
+/* Public */
+
+TransportTicket::TransportTicket(unsigned id, const char* source, const char* destination, float price) {
+ this->id = id;
+ this->source = new char[strlen(source)+1];
+ strcpy(this->source, source);
+ this->destination = new char[strlen(destination)+1];
+ strcpy(this->destination, destination);
+ this->price = price;
+}
+void TransportTicket::Print() {
+ std::cout << id << " " << source << " " << destination << " " << price << std::endl;
+}
+
+TransportTicket::TransportTicket() {
+ id = price = 0;
+ source = destination = nullptr;
+}
+TransportTicket::~TransportTicket() {
+ free();
+}
+TransportTicket::TransportTicket(const TransportTicket& other) {
+ copyFrom(other);
+}
+TransportTicket& TransportTicket::operator=(const TransportTicket& other) {
+ if (this != &other) {
+ free();
+ copyFrom(other);
+ }
+ return *this;
+}
+TransportTicket::TransportTicket(TransportTicket&& other) {
+ this->id = other.id;
+ this->source = other.source;
+ this->destination = other.destination;
+ this->price = other.price;
+
+ other.source = nullptr;
+ other.destination = nullptr;
+}
+TransportTicket& TransportTicket::operator=(TransportTicket&& other) {
+ if (this != &other) {
+ free();
+
+ this->id = other.id;
+ this->source = other.source;
+ this->destination = other.destination;
+ this->price = other.price;
+
+ other.destination = nullptr;
+ other.source = nullptr;
+ }
+ return *this;
+}
+
+void TransportTicket::SaveText(const char* fileName) {
+ std::ofstream outFile(fileName);
+ if (!outFile.is_open()) {
+ return;
+ }
+
+ outFile << id << ',' << source << ',' << destination << ',' << price;
+ outFile.close();
+}
+
+unsigned distanceUntilComma(std::ifstream& inFile) {
+ unsigned start = inFile.tellg();
+ while (inFile.peek() != ',') {
+ inFile.get();
+ }
+ unsigned len = (unsigned)inFile.tellg() - start + 1;
+ inFile.seekg(start, std::ios::beg);
+ return len;
+}
+void TransportTicket::LoadText(const char* fileName) {
+ std::ifstream inFile(fileName);
+ if (!inFile.is_open()) {
+ return;
+ }
+
+ free();
+
+ inFile >> id;
+ inFile.ignore();
+
+ unsigned sourceLen = distanceUntilComma(inFile);
+ source = new char[sourceLen+1];
+ inFile.get(source, sourceLen);
+ source[sourceLen] = '\0';
+
+ inFile.ignore();
+
+ unsigned destinationLen = distanceUntilComma(inFile);
+ destination = new char[destinationLen+1];
+ inFile.get(destination, destinationLen);
+ destination[destinationLen] = '\0';
+
+ inFile.ignore();
+ inFile >> price;
+
+ inFile.close();
+}
+
+void TransportTicket::SaveBinary(const char* fileName) {
+ std::ofstream outFile(fileName, std::ios::binary);
+ if (!outFile.is_open()) {
+ return;
+ }
+
+ outFile.write((const char*)&id, sizeof(id));
+ outFile.write((const char*)&price, sizeof(price));
+
+ unsigned sourceLen = strlen(source)+1;
+ outFile.write((const char*)&sourceLen, sizeof(sourceLen));
+ outFile.write(source, sizeof(char) * sourceLen);
+
+ unsigned destinationLen = strlen(destination)+1;
+ outFile.write((const char*)&destinationLen, sizeof(destinationLen));
+ outFile.write(destination, sizeof(char) * destinationLen);
+
+ outFile.close();
+}
+void TransportTicket::LoadBinary(const char* fileName) {
+ std::ifstream inFile(fileName, std::ios::binary);
+ if (!inFile.is_open()) {
+ return;
+ }
+
+ free();
+
+ inFile.read((char*)&id, sizeof(id));
+ inFile.read((char*)&price, sizeof(price));
+
+ unsigned sourceLen = 0;
+ inFile.read((char*)&sourceLen, sizeof(sourceLen));
+ source = new char[sourceLen+1];
+ inFile.read(source, sizeof(char) * sourceLen);
+
+ unsigned destinationLen = 0;
+ inFile.read((char*)&destinationLen, sizeof(destinationLen));
+ destination = new char[destinationLen+1];
+ inFile.read(destination, sizeof(char) * destinationLen);
+
+ inFile.close();
+}
+
+int main() {
+ TransportTicket t1(193, "Sofia", "Bourgas", 15.50);
+ t1.SaveText("t1.txt");
+
+ TransportTicket t2(782, "Sofia", "Plovdiv", 8.99);
+ t2.SaveBinary("t2.dat");
+
+ TransportTicket t3;
+ t3.LoadText("t1.txt");
+ t3.Print();
+
+ t3.LoadBinary("t2.dat");
+ t3.Print();
+}
diff --git a/week07/Exercise5.h b/week07/Exercise5.h
new file mode 100644
index 0000000..f588efa
--- /dev/null
+++ b/week07/Exercise5.h
@@ -0,0 +1,26 @@
+class TransportTicket {
+ unsigned id;
+ char* source;
+ char* destination;
+ float price;
+
+ void free();
+ void copyFrom(const TransportTicket& other);
+
+public:
+ TransportTicket(unsigned id, const char* source, const char* destination, float price);
+ void Print();
+
+ TransportTicket();
+ ~TransportTicket();
+ TransportTicket(const TransportTicket& other);
+ TransportTicket& operator=(const TransportTicket& other);
+ TransportTicket(TransportTicket&& other);
+ TransportTicket& operator=(TransportTicket&& other);
+
+ void SaveText(const char* fileName);
+ void LoadText(const char* fileName);
+
+ void SaveBinary(const char* fileName);
+ void LoadBinary(const char* fileName);
+};
diff --git a/week07/Exercise6.cpp b/week07/Exercise6.cpp
new file mode 100644
index 0000000..200f4d8
--- /dev/null
+++ b/week07/Exercise6.cpp
@@ -0,0 +1,83 @@
+#include "Exercise6.h"
+#include <iostream>
+
+/* Private */
+
+void Matrix::addBy(int amount) {
+ for (int i = 0; i < 4; i++) {
+ values[i] += amount;
+ }
+}
+
+/* Public */
+
+Matrix::Matrix(int a, int b, int c, int d) {
+ values[0] = a;
+ values[1] = b;
+ values[2] = c;
+ values[3] = d;
+}
+
+Matrix& Matrix::operator++() { // ++matrix
+ addBy(+1);
+ return *this;
+}
+Matrix Matrix::operator++(int) { // matrix++
+ Matrix copy = *this;
+ addBy(+1);
+ return copy;
+}
+Matrix& Matrix::operator--() { // --matrix
+ addBy(-1);
+ return *this;
+}
+Matrix Matrix::operator--(int) { // matrix--
+ Matrix copy = *this;
+ addBy(-1);
+ return copy;
+}
+
+Matrix& Matrix::operator+=(const Matrix& rhs) {
+ for (int i = 0; i < 4; i++) {
+ values[i] += rhs.values[i];
+ }
+ return *this;
+}
+Matrix& Matrix::operator-=(const Matrix& rhs) {
+ for (int i = 0; i < 4; i++) {
+ values[i] -= rhs.values[i];
+ }
+ return *this;
+}
+Matrix& Matrix::operator*=(const Matrix& rhs) {
+ values[0] = values[0] * rhs.values[0] + values[1] * rhs.values[2];
+ values[1] = values[0] * rhs.values[1] + values[1] * rhs.values[3];
+ values[2] = values[2] * rhs.values[0] + values[3] * rhs.values[2];
+ values[3] = values[2] * rhs.values[1] + values[3] * rhs.values[3];
+ return *this;
+}
+
+/* Friend */
+
+Matrix operator+(const Matrix& lhs, const Matrix& rhs) {
+ Matrix ret = lhs;
+ ret += rhs;
+ return ret;
+}
+Matrix operator-(const Matrix& lhs, const Matrix& rhs) {
+ Matrix ret = lhs;
+ ret -= rhs;
+ return ret;
+}
+Matrix operator*(const Matrix& lhs, const Matrix& rhs) {
+ Matrix ret = lhs;
+ ret *= rhs;
+ return ret;
+}
+
+std::ostream& operator<<(std::ostream& lhs, const Matrix& rhs) {
+ return lhs << rhs.values[0] << "," << rhs.values[1] << std::endl << rhs.values[2] << "," << rhs.values[3] << std::endl;
+}
+std::istream& operator>>(std::istream& lhs, Matrix& rhs) {
+ return lhs >> rhs.values[0] >> rhs.values[1] >> rhs.values[2] >> rhs.values[3];
+}
diff --git a/week07/Exercise6.h b/week07/Exercise6.h
new file mode 100644
index 0000000..ab5df9e
--- /dev/null
+++ b/week07/Exercise6.h
@@ -0,0 +1,27 @@
+#include <iostream>
+
+class Matrix {
+ int values[4];
+
+ void addBy(int amount);
+
+public:
+ Matrix(int a, int b, int c, int d);
+
+ Matrix& operator++();
+ Matrix operator++(int);
+ Matrix& operator--();
+ Matrix operator--(int);
+
+ Matrix& operator+=(const Matrix& rhs);
+ Matrix& operator-=(const Matrix& rhs);
+ Matrix& operator*=(const Matrix& rhs);
+
+ friend Matrix operator+(const Matrix& lhs, const Matrix& rhs);
+ friend Matrix operator-(const Matrix& lhs, const Matrix& rhs);
+ friend Matrix operator*(const Matrix& lhs, const Matrix& rhs);
+
+ friend std::ostream& operator<<(std::ostream& lhs, const Matrix& rhs);
+ friend std::istream& operator>>(std::istream& lhs, Matrix& rhs);
+};
+
diff --git a/week07/README.md b/week07/README.md
new file mode 100644
index 0000000..ea64212
--- /dev/null
+++ b/week07/README.md
@@ -0,0 +1,71 @@
+# Задачи - ООП, Седмица 7, 04.04.2024
+
+*Този файл е копие на задачите от: [syndamia.com/teaching/oop-2023/week7](https://syndamia.com/teaching/oop-2023/week7)*
+
+## Преговорни
+
+### Задача 1 - Голяма петица
+
+Една съставка е композирана от низ (с максимална дължина от 511 знака) определящ името ѝ и грамаж (число с плаваща запетая).
+
+Създайте клас `Recipe`, към който могат да се прибавят и премахват произволен брой съставки.
+Имплементирайте голяма петица (голяма четворка плюс move семантики) за него.
+
+### Задача 2 - Работа с файлове
+
+От един ред на входа получавате името на текстови файл.
+Изкарайте на екрана средната една трета от файла, като буквите са в обратен ред.
+
+## Лесни задачи
+
+### Задача 3
+
+Имплементирайте клас `Thermometer`, който запазва максималната и минималната възможна температура за измерване, както и сегашната температура, всичките които са цели неотрицателни числа.
+
+Имплементирайте методи `SaveText` и `LoadText`, които съответно записват и четат (тоест член-данните стават равни на тези от файла) данните си в/от **текстови** файл с подадено име.
+Аналогично имплементирайте `SaveBinary` и `LoadBinary`, които работят с **двоични** файлове.
+
+### Задача 4
+
+Имплементирайте клас `Street`, който запазва скрито името на улицата като низ с произволна дължина и номер като цяло число.
+Имплементирайте голяма петица.
+
+Имплементирайте методите `SaveText`, `LoadText`, `SaveBinary`, `LoadBinary`.
+
+### Задача 5
+
+За един транспортен билет е нужно скрито да пазим началната и крайната дестинация като динамично-заделени низове с произволна дължина, неговата цена като число с плаваща запетая и идентификационен номер като цяло неотрицателно число.
+
+Имплементирайте голяма петица и четирите функции за запазване и четене от файлове на съответния клас.
+
+### Задача 6
+
+Имплементирайте клас `Matrix`, който запазва стойностите на матрица 2 на 2.
+Предефинирайте операторите за инкрементиране, декрементиране, събиране, изваждане, умножение и вход/изход от/към поток.
+
+Имплементирайте четирите функции за записване и четене от файлове.
+
+### Задача 7
+
+Имплементирайте клас `Paragraph`, който съдържа текст с много редове в него.
+Текстът се запазва като низ с произволна дължина, а редовете се разделят със знака `'\n'`.
+
+Имплементирайте голяма петица.
+Имплементирайте четирите функции за записване и четене от файлове.
+
+Имплементирайте операторите за събиране, които копират текстът от подадения параграф и го вмъкват в края на сегашния; оператор[] който връща начален указател на i-тия ред; операторите за (лексикографско) сравнение; вход/изход от/към поток.
+
+## Трудни задачи
+
+### Задача 8
+
+Имплементирайте клас `MatrixNМ`, който запазва стойностите на матрица с N реда и M колони (подадени на конструктор).
+
+Имплементирайте голяма петица.
+Имплементирайте четирите функции за записване и четене от файлове.
+
+Имплементирайте операторите за събиране, изваждане, умножение и деление (нека да дефинираме деление на две матрици като умножението на първата матрица по транспонираната втората матрица върху детерминантата ѝ).
+Ако някоя операция не е възможна, върнете съответна стойност по подразбиране.
+
+Имплементирайте оператор[], като индекса i е числена конкатенация на двете координати, разделени с нула (тоест ако искаме стойността на ред 27 и колона 9, тогава ще въведем индекса 2709).
+Имплементирайте оператори за равенство, инкрементиране, декрементиране, побитово отместване (прилага се върху всяка стойност в матрицата), логически (&& връща true само ако двете матрици са равни, || връща true ако имат еднакви размерности и съществува поне един равен елемент на еднакви индекси).