businessobject.java
来自「使用netbeans 开发的 java手机通讯录。 主要就是一般的手机通讯录的」· Java 代码 · 共 62 行
JAVA
62 行
package com.lovo.addressbook;import java.util.List;public class BusinessObject { int currentPos; User[] users; PropertiesUtil proutil; private String fileName = "config/telephone.dat"; public BusinessObject(){ currentPos = 0; proutil = new PropertiesUtil(fileName); users = getAllUsers(); } public User[] getAllUsers() { List <User> list = proutil.getUsers(); User[] users2 = new User[list.size()]; for(int i =0;i<list.size();i++){ users2[i]=list.get(i); } return users2; } public User first() { currentPos =0; return users[currentPos]; } public User previous() { if(currentPos >0){ currentPos --; } return users[currentPos]; } public User next() { if(currentPos < users.length - 1){ currentPos ++; } return users[currentPos]; } public User last() { currentPos = users.length - 1; return users[currentPos]; } public void saveUser(User user) { proutil.save(user); users = getAllUsers(); currentPos = Integer.parseInt(user.getNo()) - 1; } }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?