-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser.cpp
More file actions
29 lines (22 loc) · 839 Bytes
/
Copy pathuser.cpp
File metadata and controls
29 lines (22 loc) · 839 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "user.h"
#include <fstream>
User::User() {}
User::User(std::string fn, std::string ln, int userId,std::string mailAddress,
std::string pass
)
: Person(fn, ln), userId(userId),mailAddress(mailAddress), password(pass)
{}
User::User(std::string mail, std::string pass ): mailAddress(mail),password(pass){}
std::string User::getMailAddress() const { return mailAddress; }
std::string User::getPassword() const { return password; }
int User::getUserId() const { return userId; }
void User::setPassword(const std::string &newPassword) {
password = newPassword;
}
void User::saveToFile() const {
std::ofstream file("users.txt", std::ios::app);
if (file.is_open()) {
file << firstName << "," << lastName << "," << userId << "," << mailAddress << "," << password << "\n";
file.close();
}
}