TelephoneBook-method包-TelephoneBookDB类
2015-09-01 11:20
316 查看
public class TelephoneBookDB { TelephoneMain tel = new TelephoneMain(); public String[] peoples = new String[100]; private int i = 0; Scanner sc = new Scanner(System.in); /** * 添加联系人信息 */ public void toAdd(String name, String sex, String age, String phone, String qq, String address) { while (i < 100) { String people = "姓名:" + name + ",性别:" + sex + ",年龄:" + age + ",电话:" + phone + ",QQ:" + qq + ",地址:" + address; peoples[i] = people; System.out.println(people); i++; break; } System.out.println("添加成功"); System.out.println("————————————————————华丽分割线————————————————————"); tel.mainTelephone(); } /** * 修改联系人信息 */ public void toUpdate(String name) { int temp = 1; for (int j = 0; j < i; j++) { if (peoples[j].contains(name)) { // 根据输入的名字,查找所在的条数 System.out.println("你要修改联系人的信息如下:"); System.out.println(peoples[j]); System.out.println("请输入新的信息:"); System.out.print("姓名:"); String newName = sc.nextLine(); System.out.print("性别:"); String newSex = sc.nextLine(); System.out.print("年龄:"); String newAge = sc.nextLine(); System.out.print("电话:"); String newPhone = sc.nextLine(); System.out.print("QQ:"); String newQq = sc.nextLine(); System.out.print("地址:"); String newAddress = sc.nextLine(); String newPeople = "姓名:" + newName + ",性别:" + newSex + ",年龄:" + newAge + ",电话:" + newPhone + ",QQ:" + newQq + ",地址:" + newAddress; peoples[j] = newPeople; System.out.println(newPeople); System.out.println("修改成功!"); temp = 0; System.out.println("————————————————————华丽分割线————————————————————"); tel.mainTelephone(); break; } } if (temp == 1) { System.out.println("查无此人!"); System.out.println("————————————————————华丽分割线————————————————————"); tel.mainTelephone(); } } /** * 按照姓名查找联系人信息 */ public void toQuery(String name) { int temp = 1; for (int j = 0; j < i; j++) { if (peoples[j].contains(name)) { // 根据输入的名字,查找所在的条数 System.out.println("你要查询联系人的信息如下:"); System.out.println("————————————————————华丽分割线————————————————————"); System.out.println(peoples[j]); temp = 0; System.out.println("————————————————————华丽分割线————————————————————"); tel.mainTelephone(); break; } } if (temp == 1) { System.out.println("查无此人!"); System.out.println("————————————————————华丽分割线————————————————————"); tel.mainTelephone(); } } /** * 查找所有联系人信息 */ public void toQueryAll() { System.out.println("所有联系人列表信息如下:"); System.out.println("————————————————————华丽分割线————————————————————"); for (int j = 0; j < i; j++) { System.out.println(peoples[j]); } System.out.println("————————————————————华丽分割线————————————————————"); tel.mainTelephone(); } /** * 删除联系人信息 */ public void toDele(String name) { int temp = 1; for (int j = 0; j < i; j++) { if (peoples[j].contains(name)) { // 根据输入的名字,查找所在的条数 System.out.println("你要删除联系人的信息如下:"); System.out.println(peoples[j]); System.out.println("确定要删除该联系人吗?1(是)0(否)"); int isDele = sc.nextInt(); if (isDele == 1) { peoples[j] = ""; // 重新赋值,作为删除该条信息 System.out.println("删除成功!"); System.out.println("————————————————————华丽分割线————————————————————"); tel.mainTelephone(); }else{ System.out.println("————————————————————华丽分割线————————————————————"); tel.mainTelephone(); } temp = 0; break; } } if (temp == 1) { System.out.println("查无此人!"); System.out.println("————————————————————华丽分割线————————————————————"); tel.mainTelephone(); } } }
相关文章推荐
- sublime text
- Java中两种实现多线程方式的对比分析
- Android4.4 之Bluetooth整理
- 正则表达式
- iPad开发2
- vector 插入的时候就排序
- IOS图片的高斯模糊
- iOS编程——Core Animation使用详解。
- mysql查询练习(一)
- oracle的行级锁与表级锁
- GCD
- [LeetCode#238]Product of Array Except Self
- JDK及JRE中bin工具说明
- android内存检测
- 对于 youku 客户端我很无奈
- 关于加载重新js文件
- JavaScript中this详解
- Android—判断线程池是否执行结束
- 图解Android View的scrollTo(),scrollBy(),getScrollX(), getScrollY()
- Html/javascript动态添加/删除input控件到地址定位置