-
Notifications
You must be signed in to change notification settings - Fork 1
/
Accounts.java
53 lines (42 loc) · 1.08 KB
/
Accounts.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
public class Accounts {
public class Node{
private String userName;
private String password;
private Node next;
public Node(String userName,String password) {
this.userName=userName;
this.password=password;
this.next=null;
}
}
private Node head;
public Accounts() {
this.head=null;
}// end of constructor
public void addAccount(String name, String pass) {
Node newNode = new Node(name,pass);
if(head==null) {
head = newNode;
}
else {
Node curr = head;
while(curr.next!=null) {
curr = curr.next;
}
curr.next = newNode;
}
System.out.println("Congragulations "+name+", You Have Successfully"
+ " Created A New Account, Sign In With Your "
+ " New Account To Continue");
}// end of addAccount LinkedLsit
public boolean checkAccount(String name, String pass) {
Node curr = head;
while(curr!=null) {
if(curr.userName.equals(name) && curr.password.equals(pass)) {
return true;
}
curr = curr.next;
}
return false;
}
}// end of class