当前位置:文档之家› java课程设计(通讯录管理系统)

java课程设计(通讯录管理系统)

合肥学院计算机科学与技术系课程设计报告2013~2014学年第二学期课程面向对象课程设计课程设计名称通讯录程序学生姓名XXX学号专业班级XXXXX指导教师XXX20 年月目录一、设计题目 (1)二、设计要求 (1)三、总体设计 (1)3.1系统功能框架 (1)3.2系统功能说明 (3)四、详细设计 (3)1.数据结构设计 (3)2.系统模块设计 (10)五、运行结果 (13)一.设计题目随着社会的进步与发展,通讯越来越密切。

希望能通过对java课程设计的学习和掌握来编写一个通讯录管理系统。

二.设计要求(1)只能使用Java语言,采用面向对象方法进行设计,要求源程序要有适当的注释,使程序容易阅读。

(2)程序必须与数据库进行通信。

(3)系统必须是图形用户界面的形式并连接数据库三. 总体设计3.13.2 系统功能说明(1)具有新用户注册功能。

(2)具有注册用户登录功能。

(3)具有数据的录入功能。

(4)具有数据查询功能,可以实现查询全部信息和按条件执行查询。

(5)具有按条件删除数据功能。

(6)具有统计功能4. 详细设计4.1数据结构设计(java程序设计)//登录系统package com.ibm.etp.addressbook.action;import java.util.HashMap;import java.util.List;import er;import com.ibm.etp.addressbook.service.LoginService;import com.opensymphony.xwork2.ActionSupport;public class LoginAction extends ActionSupport {private static final long serialVersionUID = 1L;public String username;public String password;private String message;@Overridepublic String execute() throws Exception {HashMap<Object, Object> result = new HashMap<Object, Object>();List<User> list = null;System.out.println(username);if(username == null || username.trim().length() == 0) {result.put("success", false);result.put("msg", "ername.empty");} else if(password == null || password.trim().length() == 0) { result.put("success", false);result.put("msg", "login.password.empty");} else {LoginService ls = new LoginService();list = ls.checkLogin(username);}if(list == null) {result.put("success", false);result.put("msg", "er.not.exist");} else if(list.get(0).getPassword().equals(password)) {result.put("success", true);result.put("msg", "login.success");} else {result.put("success", false);result.put("msg", "error.password.wrong");}if((Boolean) result.get("success")) {message = (String) result.get("msg");return "success";} else {message = (String) result.get("msg");return "error";}}public String getMessage() {return message;}public void setMessage(String message) {this.message = message;}public void setUsername(String username) {ername = username;}public void setPassword(String password) {this.password = password;}public String getUsername() {return username;}public String getPassword() {return password;}}//增加记录package com.ibm.etp.addressbook.action;import java.util.HashMap;import java.util.List;import er;import com.ibm.etp.addressbook.service.LoginService; import com.opensymphony.xwork2.ActionSupport;public class LoginAction extends ActionSupport { private static final long serialVersionUID = 1L;public String password;private String message;public String execute() throws Exception {HashMap<Object, Object> result = new HashMap<Object, Object>();List<User> list = null;System.out.println(username);if(username == null || username.trim().length() == 0) { result.put("success", false);result.put("msg", "ername.empty");} else if(password == null || password.trim().length() == 0) { result.put("success", false);result.put("msg", "login.password.empty");} else {LoginService ls = new LoginService();list = ls.checkLogin(username);}if(list == null) {result.put("success", false);result.put("msg", "er.not.exist");} else if(list.get(0).getPassword().equals(password)) { result.put("success", true);result.put("msg", "login.success");} else {result.put("success", false);result.put("msg", "error.password.wrong");}if((Boolean) result.get("success")) {message = (String) result.get("msg");return "success";} else {message = (String) result.get("msg");return "error";}}public String getMessage() {return message;}public void setMessage(String message) {this.message = message;public void setUsername(String username) {ername = username;}public void setPassword(String password) {this.password = password;}public String getUsername() {return username;}public String getPassword() {return password;}}//删除记录package com.ibm.etp.addressbook.action;import java.util.ArrayList;import com.ibm.etp.addressbook.pojo.Record;import com.ibm.etp.addressbook.service.DeleService;import com.opensymphony.xwork2.ActionSupport;public class DeleAction extends ActionSupport {private int id[];public String message;private boolean success=true;public boolean isSuccess() {return success;}private ArrayList<Record> list= new ArrayList<Record>();public ArrayList<Record> getList() {return list;}public int getId(int i){return id[i];}public int[] getId() {return id;}public void setId(int[] id) {this.id = id;public String getMessage() {return message;}public void setMessage(String message) {this.message = message;}public String execute() throws Exception {DeleService ds=new DeleService();list=ds.removeRecord(this);try {success=true;return SUCCESS;}catch (Exception e) {success=false;return ERROR;}}}//修改记录package com.ibm.etp.addressbook.action;import com.ibm.etp.addressbook.service.UpdateService; import com.opensymphony.xwork2.ActionSupport;public class UpdateAction extends ActionSupport { private int id;private String name;private String phone;private String email;private String birthday;private String sex;public int getId() {return id;}public void setId(int id) {this.id = id;}public String getName() {return name;} = name;}public String getPhone() {return phone;}public void setPhone(String phone) {this.phone = phone;}public String getEmail() {return email;}public void setEmail(String email) {this.email = email;}public String getBirthday() {return birthday;}public void setBirthday(String birthday) { this.birthday = birthday;}public String getSex() {return sex;}public void setSex(String sex) {this.sex = sex;}public String execute() throws Exception { UpdateService us=new UpdateService();if(us.setRecord(this)!=null)return SUCCESS;else{return ERROR;}}}//查找记录行package com.ibm.etp.addressbook.action;import java.sql.SQLException;import java.util.List;import com.ibm.etp.addressbook.service.FindService; import com.opensymphony.xwork2.ActionSupport; public class FindAction extends ActionSupport { private String field;private String input;private int size;private String sort;private List<Record> list ;private boolean success=true;public boolean isSuccess() {return success;}public List<Record> getList() {return list;}public void setList(List<Record> list) {this.list = list;}public String getField() {return field;}public void setField(String field) {this.field = field;}public String getInput() {return input;}public void setInput(String input) {this.input = input;}public int getSize() {return size;}public void setSize(int size) {this.size = size;}public String getSort() {return sort;public void setSort(String sort) {this.sort = sort;}public String execute() throws Exception { FindAction fb = new FindAction();fb.setField(field);fb.setInput(input);fb.setSize(size);fb.setSort(sort);FindService fs = new FindService();try {list = fs.find(fb);success=true;return SUCCESS;} catch (SQLException e) {e.printStackTrace();success=false;return ERROR;4.2 系统模块设计图1-1登陆功能展示图LoginAction类,封装的信息由密码和账户名,以及登录失败时抛出的异常方法。

相关主题