Register Then Login Then Go-F*ck-Yourself

Hi guys! I imagine a object oriented program called "Register Then Login Then Go F*ck Yourself" to practice myself. I've changed it over and over again the make the code right but I still want to know the better. Could anyone find my wrong way of programming skills that should be corrected?

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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include <iostream>
#include <string>

using namespace std;

class Account {

    public:

        Account(string username, string password, string firstName, string lastName);
        ~Account();

        string returnUsername() const;
        string returnPassword() const;
        string returnFirstName() const;
        string returnLastName() const;

    private:

        string username;
        string password;
        string firstName;
        string lastName;
};

Account::Account(string username, string password, string firstName, string lastName) {

    this->username = username;
    this->password = password;
    this->firstName = firstName;
    this->lastName = lastName;
}

Account::~Account() {}

string Account::returnUsername() const {
    return this->username;
}

string Account::returnPassword() const {
    return this->password;
}

string Account::returnFirstName() const {
    return this->firstName;
}

string Account::returnLastName() const {
    return this->lastName;
}

int main() {

    string* username = new string;
    string* password = new string;
    string* firstName = new string;
    string* lastName = new string;

    cout << "Enter the following informations required for registration" << endl << endl;

    while(1) {

        cout << "Username: ";
        cin >> *username;
        cout << "Password: ";
        cin >> *password;
        cout << "First Name: ";
        cin >> *firstName;
        cout << "Last Name: ";
        cin >> *lastName;

        if(*username != "" && *password != "" && *firstName != "" && *lastName != "") break;
        else cout << endl << "Please don't enter empty data" << endl << endl;
    }
    cout << endl << "You've successfuly registered" << endl;
    Account* jason = new Account(*username, *password, *firstName, *lastName);

    delete firstName;
    delete lastName;

    cout << endl << "Enter the following informations to login" << endl << endl;

    while(true) {

        cout << "Username: ";
        cin >> *username;
        cout << "Password: ";
        cin >> *password;

        if(*username == jason->returnUsername() && *password == jason->returnPassword()) {
            cout << endl << "Welcome, " << jason->returnFirstName() << " " << jason->returnLastName() << endl;

            delete jason;
            delete username;
            delete password;

            break;
        }
        if(*username != jason->returnUsername()) cout << endl << "Wrong username" << endl;
        if(*password != jason->returnPassword()) cout << endl << "Wrong password" << endl;
    }
    cout << endl << "Thanks for using this dumbshit c++ program! Now, go f*ck yourself LOL ^_^" << endl;
}
Last edited on
1
2
//string* username = new string;
string username;


Also, check out initialization list
Topic archived. No new replies allowed.