?? businessobject.java
字號:
public class BusinessObject {
int currentPos;
User[] users;
PropertiesUtil proutil;
public BusinessObject(){
currentPos = 0;
proutil = new PropertiesUtil("telephone.properties");
users = getAllUsers();
}
public void saveUser(User user){
proutil = new PropertiesUtil("telephone.properties");
String key = user.getNo();
proutil.setProperties(key+".no", key);
proutil.setProperties(key+".sex", user.getSex());
proutil.setProperties(key+".name", user.getName());
proutil.setProperties(key+".age", user.getAge().toString());
proutil.setProperties(key+".phone", user.getPhone());
proutil.setProperties(key+".imagePath", user.getImagePath());
proutil.save();
users = getAllUsers();
}
public User first(){
currentPos = 0;
return users[currentPos];
}
public User next(){
if(currentPos<users.length-1){
currentPos++;
return users[currentPos];
}
return users[currentPos];
}
public User previous(){
if(currentPos > 0){
currentPos--;
return users[currentPos];
}
return users[currentPos];
}
public User last(){
currentPos = users.length-1;
return users[currentPos];
}
private User[] getAllUsers() {
String[] keys = proutil.getAllKeys();
User[] users = new User[keys.length];
for(int i=0;i<keys.length;i++){
User u = new User();
u.setNo(proutil.read(keys[i]+".no"));
u.setName(proutil.read(keys[i]+".name"));
u.setAge(new Integer(proutil.read(keys[i]+".age")));
u.setPhone(proutil.read(keys[i]+".phone"));
u.setImagePath(proutil.read(keys[i]+".imagePath"));
u.setSex(proutil.read(keys[i]+".sex"));
users[i] = u;
}
return users;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -