-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFriend.java
More file actions
77 lines (58 loc) · 1.98 KB
/
Friend.java
File metadata and controls
77 lines (58 loc) · 1.98 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
import java.util.ArrayList;
import java.util.Collection;
import javax.swing.tree.TreePath;
// Friend List에서 사용할 Friend Data Class
public class Friend {
private String id;
private String nickname;
private long member_code;
// Friend Class 기본적인 정보
Friend(String id, String nickname){
this.id = id;
this.nickname = nickname;
}
Friend(String id, String nickname, long member_code){
this.id = id;
this.nickname = nickname;
this.member_code = member_code;
}
// data를 구하기 위해 Getter 새팅하기
public String getId() {
return id;
}
public String getNickName() {
return nickname;
}
public long getMemberCode() {
return member_code;
}
public void setMemberCode(long data) {
this.member_code = data ;
}
public static Friend findUsingNickname(ArrayList<Friend> fd, String nickname) {
for (Friend f : fd)
if (nickname.compareTo(f.getNickName())==0 ) return f;
return null;
}
// Friend 클래스 사용 예시
public static void main(String[] args) {
ArrayList<Friend> friendData = new ArrayList<Friend>();
friendData.add(new Friend("234", "eeee"));
friendData.add(new Friend("456", "wwerd"));
friendData.add(new Friend("riehg", "고라파덕"));
idcode_gen code_gen = new idcode_gen();
//long code = code_gen.make_member_code("234", "eeee");
//System.out.println("234" +" " + "eeee" +" "+ code);
long[] member_codes = new long[friendData.size()];
for(int i = 0; i < friendData.size(); i++) {
Friend data = friendData.get(i);
System.out.println(data.getId() +" "+ data.getNickName());
long code = code_gen.make_member_code(data.getId(), data.getNickName());
member_codes[i] = code;
}
for(int j = 0; j < friendData.size(); j++) System.out.println(member_codes[j]);
Friend foundF = findUsingNickname(friendData, "고라파덕");
System.out.println(foundF.getId() + " " + foundF.getNickName() + " was found!");
//System.out.println(a.getId() + " " + a.getNickName() );
}
}