generated from MaximTiberiu/oop-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
68a708b
commit 34b4ec4
Showing
23 changed files
with
332 additions
and
37 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CREATE TABLE IF NOT EXISTS bankaccounts ( | ||
id SERIAL references users(id), | ||
username VARCHAR(50) NOT NULL, | ||
password varchar(50) NOT NULL, | ||
IBAN varchar(50) NOT NULL, | ||
bank varchar(50) NOT NULL, | ||
constraint pk_bankaccount PRIMARY KEY (username,password,IBAN,bank) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CREATE TABLE IF NOT EXISTS emailaddresses ( | ||
id SERIAL references users(id), | ||
username VARCHAR(50) NOT NULL, | ||
password varchar(50) NOT NULL, | ||
emailAddress varchar(50) NOT NULL, | ||
mailProvider varchar(50) NOT NULL, | ||
constraint pk_bankaccount PRIMARY KEY (username,password,emailAddress,mailProvider) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CREATE TABLE IF NOT EXISTS socialmediaaccounts ( | ||
id SERIAL references users(id), | ||
username VARCHAR(50) NOT NULL, | ||
password varchar(50) NOT NULL, | ||
platform varchar(50) NOT NULL, | ||
profileUrl varchar(50) NOT NULL, | ||
constraint pk_bankaccount PRIMARY KEY (username,password,platform,profileUrl) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include "Account.h" | ||
|
||
Account::Account(const std::string &username, const std::string &password) : | ||
username(username), password(password) {} | ||
|
||
std::string Account::getUsername() const { | ||
return this->username; | ||
} | ||
|
||
std::string Account::getPassword() const { | ||
return this->password; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#ifndef ACCOUNT_H | ||
#define ACCOUNT_H | ||
#include <string> | ||
|
||
enum AccountType { | ||
BankAccountType, | ||
EmailAccountType, | ||
SocialMediaAccountType | ||
}; | ||
|
||
class Account { | ||
protected: | ||
std::string username; | ||
std::string password; | ||
[[nodiscard]] virtual AccountType getAccountType() const = 0; | ||
public: | ||
Account(const std::string&, const std::string&); | ||
virtual void addAccount() = 0; | ||
virtual ~Account() = default; | ||
|
||
virtual std::string getUsername() const; | ||
virtual std::string getPassword() const; | ||
}; | ||
|
||
|
||
|
||
#endif //ACCOUNT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include "BankAccount.h" | ||
|
||
#include <Database.h> | ||
|
||
#include <utility> | ||
|
||
BankAccount::BankAccount(const std::string &username, const std::string &password, | ||
std::string IBAN, std::string bank) | ||
: Account(username,password), IBAN(std::move(IBAN)), bank(std::move(bank)){} | ||
|
||
AccountType BankAccount::getAccountType() const { | ||
return BankAccountType; | ||
} | ||
|
||
void BankAccount::addAccount() { | ||
const Database &database = Database::getDatabaseInstance(); | ||
const auto bankAccount = std::make_shared<BankAccount>(*this); | ||
database.addUserDefinedAccount(bankAccount, this->getAccountType()); | ||
} | ||
|
||
std::string BankAccount::getIBAN() const { | ||
return this->IBAN; | ||
} | ||
|
||
std::string BankAccount::getBank() const { | ||
return this->bank; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#ifndef BANKACCOUNT_H | ||
#define BANKACCOUNT_H | ||
#include "Account.h" | ||
|
||
|
||
class BankAccount final : public Account { | ||
std::string IBAN; | ||
std::string bank; | ||
[[nodiscard]] AccountType getAccountType() const override; | ||
public: | ||
BankAccount(const std::string &, const std::string &, std::string , std::string ); | ||
void addAccount() override; | ||
|
||
[[nodiscard]] std::string getIBAN() const; | ||
[[nodiscard]] std::string getBank() const; | ||
}; | ||
|
||
|
||
|
||
#endif //BANKACCOUNT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#include "EmailAccount.h" | ||
|
||
#include <Database.h> | ||
|
||
AccountType EmailAccount::getAccountType() const { | ||
return EmailAccountType; | ||
} | ||
|
||
EmailAccount::EmailAccount(const std::string &username, const std::string &password, | ||
const std::string &emailAddress, const std::string &mailProvider) | ||
: Account(username, password), emailAddress(emailAddress), mailProvider(mailProvider) {} | ||
|
||
void EmailAccount::addAccount() { | ||
const Database &database = Database::getDatabaseInstance(); | ||
const auto emailAccount = std::make_shared<EmailAccount>(*this); | ||
database.addUserDefinedAccount(emailAccount, this->getAccountType()); | ||
} | ||
|
||
std::string EmailAccount::getEmailAddress() const { | ||
return this->emailAddress; | ||
} | ||
|
||
std::string EmailAccount::getMailProvider() const { | ||
return this->mailProvider; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#ifndef EMAILACCOUNT_H | ||
#define EMAILACCOUNT_H | ||
#include "Account.h" | ||
|
||
|
||
class EmailAccount final: public Account { | ||
std::string emailAddress; | ||
std::string mailProvider; | ||
[[nodiscard]] AccountType getAccountType() const override; | ||
public: | ||
explicit EmailAccount(const std::string&, const std::string&, const std::string&, const std::string&); | ||
|
||
void addAccount() override; | ||
|
||
[[nodiscard]] std::string getEmailAddress() const; | ||
[[nodiscard]] std::string getMailProvider() const; | ||
}; | ||
|
||
|
||
|
||
#endif //EMAILACCOUNT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#include "SocialMediaAccount.h" | ||
|
||
#include <Database.h> | ||
|
||
AccountType SocialMediaAccount::getAccountType() const { | ||
return SocialMediaAccountType; | ||
} | ||
|
||
SocialMediaAccount::SocialMediaAccount(const std::string &username, const std::string& password, | ||
const std::string &platform, const std::string & profileUrl) | ||
: Account(username, password), platform(platform), profileUrl(profileUrl) {} | ||
|
||
void SocialMediaAccount::addAccount() { | ||
const Database &database = Database::getDatabaseInstance(); | ||
const auto emailAccount = std::make_shared<SocialMediaAccount>(*this); | ||
database.addUserDefinedAccount(emailAccount, this->getAccountType()); | ||
} | ||
|
||
std::string SocialMediaAccount::getPlatform() const { | ||
return this->platform; | ||
} | ||
|
||
std::string SocialMediaAccount::getProfileUrl() const { | ||
return this->profileUrl; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#ifndef SOCIALMEDIAACCOUNT_H | ||
#define SOCIALMEDIAACCOUNT_H | ||
#include "Account.h" | ||
|
||
|
||
class SocialMediaAccount final : public Account { | ||
std::string platform; | ||
std::string profileUrl; | ||
[[nodiscard]] AccountType getAccountType() const override; | ||
public: | ||
SocialMediaAccount(const std::string&, const std::string&, const std::string&, const std::string&); | ||
|
||
void addAccount() override; | ||
|
||
[[nodiscard]] std::string getPlatform() const; | ||
[[nodiscard]] std::string getProfileUrl() const; | ||
}; | ||
|
||
|
||
|
||
#endif //SOCIALMEDIAACCOUNT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "DatabaseExceptions.h" |
Oops, something went wrong.