-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDataFactory.java
More file actions
63 lines (50 loc) · 1.73 KB
/
Copy pathDataFactory.java
File metadata and controls
63 lines (50 loc) · 1.73 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
/*******************************************************************************
* CSCI Assignment
* Filename: ${filename}
* Author: Nguyen Van Thanh Huy (Nick Nguyen)
* UOW Student Number: 5216746
* Description:
*
*******************************************************************************/
import java.io.*;
import java.util.*;
import Basic.Member;
import Basic.User;
import Common.DBQuery;
//import Game.Card;
public class DataFactory {
public static ArrayList<User> getAllMembers() {
ArrayList<User> MemberList = new ArrayList<User>();
// if the storage of Members' data is changed to a xml file
// or a database, we just need to change this part of the code.
// Concept of Information Hiding
// In computer science, information hiding is the principle of
// segregation of the design decisions in a computer program that
// are most likely to change, thus protecting other parts of the program
// from extensive modification if the design decision is changed.
// try {
// Scanner fileScanner = new Scanner(new File("Members.dat"));
//
// while (fileScanner.hasNextLine()) {
// String data = fileScanner.nextLine();
// String[] dataArray = data.split("\\|");
// String loginName = dataArray[0];
// String hashedPassword = dataArray[1];
// String chipsString = dataArray[2];
// int chips = Integer.parseInt(chipsString);
//
// Member p = new Member(loginName, hashedPassword, chips);
// MemberList.add(p);
// }
//
// fileScanner.close();
//
// } catch (FileNotFoundException ex) {
// System.out.println("Members.dat not found.");
//
// }
DBQuery query = new DBQuery();
MemberList = query.runGetMemberListQuery("Select * from User");
return MemberList;
}
}