forked from tperamun2/Phillips-Hue-Lighting-System
-
Notifications
You must be signed in to change notification settings - Fork 0
/
User.cpp
74 lines (67 loc) · 1.56 KB
/
User.cpp
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//
// UserBook.cpp
//
// Store standard user data including firstname,lastname,email, and password in strings
// Created by Jake Schindler
//
//
#include "User.h"
#include <string>
using namespace std;
User::User(){
firstName ="";
lastName ="";
email ="";
password ="";
}
/*
NAME: update: User
initializes a user with all its info
PARAMS: strings -firstname,lastname, email, password
RETURN: void
*/
void User::update(std::string fName, std::string lName, std::string em, std::string pass){
firstName =fName;
lastName =lName;
email = em;
password = pass;
Persistence::storeUser(fName, lName, em, pass);
}
/*
* getters and setters
*/
string User::getFirstName() {
return firstName;
}
void User::setFirstName(string name) {
this->firstName = name;
std::string email = this->email;
Persistence::setFirstName(email, name);
}
string User::getLastName() {
return lastName;
}
void User::setLastName(string name) {
this->lastName = name;
std::string email = this->email;
Persistence::setLastName(email, name);
}
string User::getEmail() {
return email;
}
void User::setEmail(string newemail){
std::string oldemail = this->email;
std::string filename = oldemail + ".txt";
const char * c = filename.c_str();
this->email = newemail;
Persistence::setEmail(oldemail, newemail);
remove(c);
}
string User::getPassword() {
return password;
}
void User::setPassword(string password) {
this->password = password;
std::string email = this->email;
Persistence::setPassword(email, password);
}