/
Account.java
57 lines (49 loc) · 1.95 KB
/
Account.java
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
//********************************************************************
// Author: Ella Withington
//
// Methods for getting a username, verifying a password,
// changing a password, and printing account information
//********************************************************************
public abstract class Account {
protected String username;
protected String password;
//-----------------------------------------------------------------
// Constructor: Sets up this account with username and password.
//-----------------------------------------------------------------
public Account(String uname, String pwd) {
username = uname;
password = pwd;
}
//-----------------------------------------------------------------
// Returns true or false for correct or incorrect account password.
//-----------------------------------------------------------------
public Boolean verifyPassword(String enteredPassword) {
if (enteredPassword.equals(password)) {
return true;
} else {
return false;
}
}
//-----------------------------------------------------------------
//Added by Lily
//returns the Username
//-----------------------------------------------------------------
public String getUsername()
{
return ""+username;
}
//-----------------------------------------------------------------
// Verifies password then changes account password.
//-----------------------------------------------------------------
public void setPassword(String pwd) {
String newPassword = pwd;//shouldnt this change the password variable? -Lily
}
//-----------------------------------------------------------------
// Returns information about an account as a string.
//-----------------------------------------------------------------
public String toString() {
String result = super.toString();
result = "\nUsername: " + username + "\nClass Type: " + super.getClass();
return result;
}
}