-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNested.java
More file actions
90 lines (59 loc) · 2.13 KB
/
Nested.java
File metadata and controls
90 lines (59 loc) · 2.13 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
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
import java.util.*;
public class Nested {
public static void main(String[] args) {
Nested mainDisplay = new Nested();
mainDisplay.input();
}
//Method
private void input(){
Scanner console = new Scanner(System.in);
System.out.print("Enter first name: ");
String firstname = console.nextLine();
System.out.print("Enter last name: ");
String lastname = console.nextLine();
enteredData(firstname,lastname);
}
private void enteredData(String firstname, String lastname){
User user = new User();
User.AccountCreation userCreate = user.new AccountCreation();
User.DataStoring dataHandle = new User.DataStoring();
userCreate.setFirstName(firstname);
userCreate.setLastName(lastname);
new User.DataStoring(firstname, userCreate);
User.AccountCreation x = dataHandle.viewData(firstname);
System.out.println("Output: \n"+ x.getFirstName() +"\n"+x.getLastName());
}
}
class User{
class AccountCreation{
private String lastName = "";
private String firstName = "";
//Method
//Getter
public String getFirstName(){
return this.firstName;
}
public String getLastName(){
return this.lastName;
}
//Setter
public void setLastName(String lastname){
this.lastName= lastname;
}
public void setFirstName(String firstname){
this.firstName = firstname;
}
}
//Storing Data
static class DataStoring{
static HashMap<String,AccountCreation> data = new HashMap<String,AccountCreation>();
DataStoring(){}
DataStoring(String firstname,AccountCreation x){
data.put(firstname,x);
}
//
public AccountCreation viewData(String firstname){
return data.get(firstname);
}
}
}