diff --git a/README.md b/README.md
index 54241e5..b37f3fc 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,3 @@
-
\ No newline at end of file
+
+
+[Dokumentation](https://files.joethei.space/documentation/Studium/C_CPP/)
\ No newline at end of file
diff --git a/src/10_PITF/Testat/Bank.cpp b/src/10_PITF/Testat/Bank.cpp
index f95fa93..60ba555 100644
--- a/src/10_PITF/Testat/Bank.cpp
+++ b/src/10_PITF/Testat/Bank.cpp
@@ -6,6 +6,8 @@
#include "Bank.h"
+using namespace banking;
+
std::default_random_engine gen(static_cast(time(nullptr)));
std::uniform_int_distribution dist(0, 9000);
@@ -13,7 +15,7 @@ Bank::Bank(std::string name) : name(std::move(name)) {}
Bank::Bank(Bank *bank) : name(std::move(bank->getName())) {}
-void Bank::addAccount(BankAccount * account) {
+void Bank::addAccount(BankAccount *account) {
accounts.insert(std::move(std::make_unique(account)));
}
@@ -21,8 +23,8 @@ void Bank::moveMoney(std::shared_ptr bank, int amount) {
//ab und zu etwas Geld verlieren
int chance = dist(gen);
int value = dist(gen);
- if(chance == 42 && amount >= value) {
- amount -=value;
+ if (chance == 42 && amount >= value) {
+ amount -= value;
}
money -= amount;
bank->money -= amount;
@@ -36,3 +38,4 @@ std::string Bank::getName() {
return name;
}
+
diff --git a/src/10_PITF/Testat/Bank.h b/src/10_PITF/Testat/Bank.h
index 922ee05..542811a 100644
--- a/src/10_PITF/Testat/Bank.h
+++ b/src/10_PITF/Testat/Bank.h
@@ -4,18 +4,32 @@
#include "BankAccount.h"
#include "HeapObject.h"
-class Bank : public HeapObject{
-private:
- std::string name;
- std::set> accounts;
- int money;
-public:
- explicit Bank(std::string name);
- explicit Bank(Bank* bank);
- void addAccount(BankAccount * account);
- void moveMoney(std::shared_ptr bank, int amount);
- std::set> getAccounts();
- std::string getName();
-};
+
+namespace banking {
+
+ /**
+ * @author Johannes Theiner
+ * @version 1.0
+ */
+ class Bank : public HeapObject {
+ private:
+ std::string name;
+ std::set> accounts;
+ int money;
+ public:
+ explicit Bank(std::string name);
+
+ explicit Bank(Bank *bank);
+
+ void addAccount(BankAccount *account);
+
+ void moveMoney(std::shared_ptr bank, int amount);
+
+ std::set> getAccounts();
+
+ std::string getName();
+ };
+
+}
#endif
\ No newline at end of file
diff --git a/src/10_PITF/Testat/BankAccount.cpp b/src/10_PITF/Testat/BankAccount.cpp
index e695b57..e5b3f3b 100644
--- a/src/10_PITF/Testat/BankAccount.cpp
+++ b/src/10_PITF/Testat/BankAccount.cpp
@@ -8,6 +8,8 @@
#include "BankAccount.h"
#include "CashFactory.h"
+using namespace banking;
+
std::default_random_engine gen2(static_cast(time(nullptr)));
std::uniform_int_distribution dist2(0, 9000);
@@ -22,7 +24,7 @@ BankAccount::BankAccount(BankAccount *bankAccount) : name(std::move(bankAccount-
}
-BankAccount *BankAccount::operator+(Money * money) {
+BankAccount *BankAccount::operator+(std::shared_ptr money) {
//ab und zu Geld verlieren
int rnd = dist2(gen2);
diff --git a/src/10_PITF/Testat/BankAccount.h b/src/10_PITF/Testat/BankAccount.h
index e24dd39..d60dcb2 100644
--- a/src/10_PITF/Testat/BankAccount.h
+++ b/src/10_PITF/Testat/BankAccount.h
@@ -7,19 +7,33 @@
#include "Money.h"
#include "Person.h"
-class BankAccount {
-private:
- std::string name;
- std::shared_ptr owner;
- std::shared_ptr money;
-public:
- explicit BankAccount(std::shared_ptr owner, std::string name);
- explicit BankAccount(BankAccount* bankAccount);
- BankAccount* operator+(Money * money);
- Money* operator-(int value);
- std::string getName();
- std::shared_ptr getOwner();
- std::shared_ptr getMoney();
-};
+namespace banking {
+
+ /**
+ * @author Johannes Theiner
+ * @version 1.0
+ */
+ class BankAccount {
+ private:
+ std::string name;
+ std::shared_ptr owner;
+ std::shared_ptr money;
+ public:
+ explicit BankAccount(std::shared_ptr owner, std::string name);
+
+ explicit BankAccount(BankAccount *bankAccount);
+
+ BankAccount *operator+(std::shared_ptr money);
+
+ Money *operator-(int value);
+
+ std::string getName();
+
+ std::shared_ptr getOwner();
+
+ std::shared_ptr getMoney();
+ };
+}
+
#endif
\ No newline at end of file
diff --git a/src/10_PITF/Testat/Bill.cpp b/src/10_PITF/Testat/Bill.cpp
index d35ba2f..5bf83a9 100644
--- a/src/10_PITF/Testat/Bill.cpp
+++ b/src/10_PITF/Testat/Bill.cpp
@@ -2,6 +2,8 @@
#include "Bill.h"
+using namespace banking;
+
Bill::Bill(int value, Currency currency, std::string serial) : Cash(value, currency), serial(std::move(serial)){
}
diff --git a/src/10_PITF/Testat/Bill.h b/src/10_PITF/Testat/Bill.h
index bfa2aa2..0a28571 100644
--- a/src/10_PITF/Testat/Bill.h
+++ b/src/10_PITF/Testat/Bill.h
@@ -4,15 +4,24 @@
#include "Cash.h"
-class Bill : public Cash{
-private:
- std::string serial;
-public:
- explicit Bill(int value, Currency currency, std::string serial);
- explicit Bill(Bill *bill);
- std::string getSerial();
- int getValue();
-};
+namespace banking {
+
+ /**
+ * @author Johannes Theiner
+ * @version 1.0
+ */
+ class Bill : public Cash{
+ private:
+ std::string serial;
+ public:
+ explicit Bill(int value, Currency currency, std::string serial);
+ explicit Bill(Bill *bill);
+ std::string getSerial();
+ int getValue() override;
+ };
+}
+
+
#endif
\ No newline at end of file
diff --git a/src/10_PITF/Testat/Cash.cpp b/src/10_PITF/Testat/Cash.cpp
index 8209bfa..e8be900 100644
--- a/src/10_PITF/Testat/Cash.cpp
+++ b/src/10_PITF/Testat/Cash.cpp
@@ -3,4 +3,6 @@
#include "Cash.h"
+using namespace banking;
+
Cash::Cash(int value, Currency currency) : Money(value, currency) {}
\ No newline at end of file
diff --git a/src/10_PITF/Testat/Cash.h b/src/10_PITF/Testat/Cash.h
index bbf3f5d..e914b2c 100644
--- a/src/10_PITF/Testat/Cash.h
+++ b/src/10_PITF/Testat/Cash.h
@@ -5,10 +5,19 @@
#include "Money.h"
#include "HeapObject.h"
-class Cash : public Money, public HeapObject{
-private:
-public:
- Cash(int value, Currency currency);
-};
+namespace banking {
+
+ /**
+ * @author Johannes Theiner
+ * @version 1.0
+ */
+ class Cash : public Money, public HeapObject{
+ private:
+ public:
+ Cash(int value, Currency currency);
+ };
+}
+
+
#endif
diff --git a/src/10_PITF/Testat/CashFactory.cpp b/src/10_PITF/Testat/CashFactory.cpp
index d01e567..e1016fe 100644
--- a/src/10_PITF/Testat/CashFactory.cpp
+++ b/src/10_PITF/Testat/CashFactory.cpp
@@ -1,6 +1,8 @@
#include
#include "CashFactory.h"
+using namespace banking;
+
int allowedBills[5] = {100, 50, 20, 10, 5};
int allowedCoins[8] = {1, 2, 5, 10, 20, 50, 100, 200};
diff --git a/src/10_PITF/Testat/CashFactory.h b/src/10_PITF/Testat/CashFactory.h
index 5cf3e83..c2e00b3 100644
--- a/src/10_PITF/Testat/CashFactory.h
+++ b/src/10_PITF/Testat/CashFactory.h
@@ -7,12 +7,20 @@
#include "Bill.h"
#include "Coin.h"
-class CashFactory {
-private:
- std::string randomString(size_t length);
-public:
- std::shared_ptr printBill(int value, Currency currency);
- std::shared_ptr printCoin(int value, Currency currency);
-};
+namespace banking {
+
+ /**
+ * @author Johannes Theiner printBill(int value, Currency currency);
+ std::shared_ptr printCoin(int value, Currency currency);
+ };
+}
+
#endif
\ No newline at end of file
diff --git a/src/10_PITF/Testat/Coin.cpp b/src/10_PITF/Testat/Coin.cpp
index ac833af..923594a 100644
--- a/src/10_PITF/Testat/Coin.cpp
+++ b/src/10_PITF/Testat/Coin.cpp
@@ -1,5 +1,7 @@
#include "Coin.h"
+using namespace banking;
+
Coin::Coin(int value, Currency currency) : Cash(value, currency) {
}
diff --git a/src/10_PITF/Testat/Coin.h b/src/10_PITF/Testat/Coin.h
index b4f54f5..be6db82 100644
--- a/src/10_PITF/Testat/Coin.h
+++ b/src/10_PITF/Testat/Coin.h
@@ -4,12 +4,21 @@
#include "Cash.h"
-class Coin : public Cash{
-private:
-public:
- explicit Coin(int value, Currency currency);
- explicit Coin(Coin *coin);
- int getValue() override;
-};
+namespace banking {
+
+ /**
+ * @author Johannes Theiner
+ * @version 1.0
+ */
+ class Coin : public Cash{
+ private:
+ public:
+ explicit Coin(int value, Currency currency);
+ explicit Coin(Coin *coin);
+ int getValue() override;
+ };
+}
+
+
#endif
diff --git a/src/10_PITF/Testat/Currency.cpp b/src/10_PITF/Testat/Currency.cpp
index 181d96d..22765a4 100644
--- a/src/10_PITF/Testat/Currency.cpp
+++ b/src/10_PITF/Testat/Currency.cpp
@@ -1,6 +1,8 @@
#include
#include "Currency.h"
+using namespace banking;
+
Currency::Currency(CurrencyValue value) : value(value) {
}
diff --git a/src/10_PITF/Testat/Currency.h b/src/10_PITF/Testat/Currency.h
index 469346c..00feeb3 100644
--- a/src/10_PITF/Testat/Currency.h
+++ b/src/10_PITF/Testat/Currency.h
@@ -3,21 +3,31 @@
#include
-enum class CurrencyValue {
- USD=100,
- EUR=80,
- GPD=75,
-};
+namespace banking {
+
+ enum class CurrencyValue {
+ USD=100,
+ EUR=80,
+ GPD=75,
+ };
+
+
+ /**
+ * @author Johannes Theiner
+ * @version 1.0
+ */
+ class Currency {
+ private:
+ CurrencyValue value;
+ public:
+ Currency(CurrencyValue value);
+ bool operator==(Currency ¤cy);
+ Currency& operator=(Currency currency);
+ CurrencyValue getValue();
+
+ };
+}
-class Currency {
-private:
- CurrencyValue value;
-public:
- Currency(CurrencyValue value);
- bool operator==(Currency ¤cy);
- Currency& operator=(Currency currency);
- CurrencyValue getValue();
-};
#endif
\ No newline at end of file
diff --git a/src/10_PITF/Testat/HeapObject.cpp b/src/10_PITF/Testat/HeapObject.cpp
index d12b035..b4b4ba3 100644
--- a/src/10_PITF/Testat/HeapObject.cpp
+++ b/src/10_PITF/Testat/HeapObject.cpp
@@ -12,9 +12,6 @@ void* HeapObject::operator new (size_t size){
return new char[size];
}
-
-
-
HeapObject::HeapObject(){
ctorCount++;
}
@@ -24,8 +21,7 @@ HeapObject::~HeapObject(){
}
bool HeapObject::assertionsHold(){
- //assert(ctorCount == newCount); // all objects have been allocated on heap
- std::cout << ctorCount << " : " << dtorCount << std::endl;
+ assert(ctorCount == newCount); // all objects have been allocated on heap
assert(ctorCount == dtorCount); // all objects have been deleted
return true;
}
\ No newline at end of file
diff --git a/src/10_PITF/Testat/HeapObject.h b/src/10_PITF/Testat/HeapObject.h
index 58870ca..ad627c2 100644
--- a/src/10_PITF/Testat/HeapObject.h
+++ b/src/10_PITF/Testat/HeapObject.h
@@ -3,6 +3,10 @@
#include
+/**
+ * @author Carsten Link
+ * @version 1.0
+ */
class HeapObject {
public:
void *operator new(size_t size);
diff --git a/src/10_PITF/Testat/Money.cpp b/src/10_PITF/Testat/Money.cpp
index 3c62ef8..0013d61 100644
--- a/src/10_PITF/Testat/Money.cpp
+++ b/src/10_PITF/Testat/Money.cpp
@@ -1,6 +1,8 @@
#include
#include "Money.h"
+using namespace banking;
+
Money::Money(int value, Currency currency) : value(value), currency(currency) {}
Money::Money(Money *money) : value(money->getValue()), currency(money->getCurrency()) {}
diff --git a/src/10_PITF/Testat/Money.h b/src/10_PITF/Testat/Money.h
index 225f05d..ab8dad1 100644
--- a/src/10_PITF/Testat/Money.h
+++ b/src/10_PITF/Testat/Money.h
@@ -3,23 +3,40 @@
#include "Currency.h"
-class Money {
-private:
- int value;
- Currency currency;
-public:
- explicit Money(int value = 0, Currency currency = CurrencyValue::USD);
- explicit Money(Money *money);
- Money& operator=(Money money);
- Money& operator=(Money * money);
- Money operator+(Money &a);
- Money operator-(Money &a);
- const Money operator++(int);
- const Money operator--(int);
- bool operator<(Money &a);
+namespace banking {
+
+ /**
+ * @author Johannes Theiner
+ * @version 1.0
+ */
+ class Money {
+ private:
+ int value;
+ Currency currency;
+ public:
+ explicit Money(int value = 0, Currency currency = CurrencyValue::USD);
+
+ explicit Money(Money *money);
+
+ Money &operator=(Money money);
+
+ Money &operator=(Money *money);
+
+ Money operator+(Money &a);
+
+ Money operator-(Money &a);
+
+ const Money operator++(int);
+
+ const Money operator--(int);
+
+ bool operator<(Money &a);
+
+ virtual int getValue();
+
+ Currency getCurrency();
+ };
+}
- virtual int getValue();
- Currency getCurrency();
-};
#endif
diff --git a/src/10_PITF/Testat/Person.cpp b/src/10_PITF/Testat/Person.cpp
index 166df44..205235b 100644
--- a/src/10_PITF/Testat/Person.cpp
+++ b/src/10_PITF/Testat/Person.cpp
@@ -2,6 +2,8 @@
#include "Person.h"
+using namespace banking;
+
Person::Person(std::string name) : name(std::move(name)){
}
diff --git a/src/10_PITF/Testat/Person.h b/src/10_PITF/Testat/Person.h
index bd0da66..713c7b2 100644
--- a/src/10_PITF/Testat/Person.h
+++ b/src/10_PITF/Testat/Person.h
@@ -6,15 +6,24 @@
#include
#include "Money.h"
-class Person {
-private:
- std::string name;
- std::vector> money;
-public:
- explicit Person(std::string name);
- explicit Person(Person* person);
- std::string getName();
-};
+namespace banking {
+
+ /**
+ * @author Johannes Theiner
+ * @version 1.0
+ */
+ class Person {
+ private:
+ std::string name;
+ std::vector> money;
+ public:
+ explicit Person(std::string name);
+
+ explicit Person(Person *person);
+
+ std::string getName();
+ };
+}
#endif
diff --git a/src/10_PITF/Testat/main.cpp b/src/10_PITF/Testat/main.cpp
index 010c04f..f9bdc00 100644
--- a/src/10_PITF/Testat/main.cpp
+++ b/src/10_PITF/Testat/main.cpp
@@ -8,6 +8,8 @@
#include "CashFactory.h"
#include "Bank.h"
+using namespace banking;
+
std::default_random_engine generator(static_cast(time(nullptr)));
std::uniform_int_distribution distribution(-100, 500);
@@ -93,11 +95,11 @@ void simulate() {
std::shared_ptr bill = cashFactory->printBill(rnd, CurrencyValue::USD);
std::shared_ptr coin = cashFactory->printCoin(rnd, CurrencyValue::USD);
if (bill != nullptr) {
- *bankAccount + bill.get();
+ *bankAccount + bill;
moneyVector.push_back(std::static_pointer_cast(bill));
}
if (coin != nullptr) {
- *bankAccount + coin.get();
+ *bankAccount + coin;
moneyVector.push_back(std::static_pointer_cast(coin));
}
Money *fee = *bankAccount - 10;