-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGuest.cpp
More file actions
65 lines (53 loc) · 1.31 KB
/
Guest.cpp
File metadata and controls
65 lines (53 loc) · 1.31 KB
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
#include <iostream>
#include "Guest.hpp"
#include "Customer.hpp"
#include "Shared_Variables.hpp"
#include "University.hpp"
using namespace std;
Guest::Guest()
{
}
Guest::~Guest()
{
}
bool Guest::registerAccount(string username, string email, string password, time_t lastLoginTime)
{
//Check if username already exists
CustomerNode* temp = customerList.getHead();
while (temp != nullptr)
{
if (temp->customer.getUsername() == username)
{
cout << "Username already exists!" << endl;
return false;
}
else
{
temp = temp->nextCustomer;
}
}
string customerID = customerList.generateCustomerID();
time_t rawTime = time(nullptr);
struct tm* loginTime = localtime(&rawTime);
customerList.insertEnd(customerID, username, email, password, *loginTime);
return true;
}
void Guest::displayUniversity()
{
uniList.displayList(uniList.getHead(), -1, "Guest");
}
void Guest::sortUniversityByName()
{
uniList.sortByName();
uniList.displayList(uniList.getHead(), -1, "Guest");
}
void Guest::searchUniversityByName()
{
cin.ignore();
uniList.searchUniversities(FieldName::INSTITUTION_NAME, "Guest");
}
void Guest::searchUniversityByLocation()
{
cin.ignore();
uniList.searchUniversities(FieldName::LOCATION, "Guest");
}