第一篇:个人通讯录管理系统,java源代码
package cn.pab.manager;
import java.util.List;import java.util.Scanner;
import cn.pab.dao.PersonDao;import cn.pab.dao.TypeDao;import cn.pab.dao.UserDao;import cn.pab.dao.impl.PersonDaoImpl;import cn.pab.dao.impl.TypeDaoImpl;import cn.pab.dao.impl.UserDaoImpl;import cn.pab.entity.Person;import cn.pab.entity.Type;/** * 业务类
*/ public class PABmanager { /**
* 系统启动
*/ public static void main(String[] args){
Scanner input = new Scanner(System.in);
UserDao userDao = new UserDaoImpl();
TypeDao typeDao = new TypeDaoImpl();
PersonDao personDao = new PersonDaoImpl();
System.out.println(“***********欢迎使用个人通讯录管理系统**********”);
System.out.print(“n请选择操作(1.系统登录
2.密码修改
3.取消):”);
String in = input.next();
if(“1”.equals(in)){
boolean islogin = userDao.login();
if(islogin){
System.out.println(“***********成功登录个人通讯录管理系统**********”);
//System.out.print(“n请选择操作(1.类别管理
2.联系人管理
3.退出系统):”);
}else{
System.out.println(“用户名或密码错误,不能登录!”);
System.exit(-1);
}
}else if(“2”.equals(in)){
boolean modiFlag = userDao.modify();
if(modiFlag){
System.out.println(“密码修改成功!”);}else{
System.out.println(“密码修改失败!”);} System.exit(-1);}else{ System.out.println(“您已经退出系统!”);System.exit(-1);}
while(true){
System.out.print(“n请选择操作(1.类别管理
2.联系人管理
3.退出系统):”);String in2 = input.next();if(“1”.equals(in2)){ while(true){
System.out.print(“n请继续选择操作(1.新建类别
2.查询类别
3.删除类别
4.返回):”);
String num = input.next();
if(“1”.equals(num)){
System.out.print(“请输入类别的名称:”);String lbmc = input.next();
System.out.print(“请输入类别的说明:”);String lbsm = input.next();System.out.print(“请输入类别的备注:”);String lbbz = input.next();
Type type = new Type(lbmc,lbsm,lbbz);
typeDao.createType(type);}else if(“2”.equals(num)){ List
System.out.println(“tt类别信息列表”);
System.out.println(“类别名称tt类别说明tt类别备注”);
for(int i = 0;i < types.size();i++){
Type type =types.get(i);
System.out.print(type.getLbmc()+“t”);
System.out.print(type.getLbsm()+ “tt”);
System.out.println(type.getLbbz());
}
}else if(“3”.equals(num)){
System.out.print(“请输入类别的名称:”);
String lbmc = input.next();
Type type = new Type(lbmc,null,null);
typeDao.deleteType(type);}else if(“4”.equals(num)){ break;}else{
System.out.println(“您输入不合法,请重新选择!”);
}
} }else if(“2”.equals(in2)){
while(true){
System.out.print(“n请继续选择操作(1.新建联系人
2.查询联系人
3.更新联系人
4.删除联系人
5.返回):”);
String num = input.next();
if(“1”.equals(num)){
System.out.print(“请输入联系人的类别名称:”);String lb = input.next();
System.out.print(“请输入联系人的姓名:”);String xm = input.next();
System.out.print(“请输入联系人的电话:”);String dh = input.next();
System.out.print(“请输入联系人的手机号:”);String sjh = input.next();
System.out.print(“请输入联系人的工作单位:”);String gzdw = input.next();
System.out.print(“请输入联系人的住址:”);
String zz = input.next();
System.out.print(“请输入联系人的邮政编码:”);
String yzbm = input.next();
Person person = new Person(lb,xm,dh,sjh,gzdw,zz,yzbm);
personDao.createPerson(person);
}else if(“2”.equals(num)){
System.out.print(“请输入联系人的姓名:”);
String name = input.next();
Person p = personDao.queryPerson(name);
System.out.println(“tt查询到的联系人信息”);
System.out.println(“类别t姓名t电话tt手机号tt工作单位t住址t邮政编码”);
System.out.print(p.getLb()+ “t”);
System.out.print(p.getXm()+ “t”);
System.out.print(p.getDh()+ “t”);
System.out.print(p.getSjh()+ “t”);
System.out.print(p.getGzdw()+ “t”);
System.out.print(p.getZz()+ “t”);
System.out.println(p.getYzbm());
}
} }
}else if(“3”.equals(num)){
System.out.print(“请输入需更新的联系人编号:”);
int id = input.nextInt();
System.out.print(“请输入需更新的联系人信息选项:”);
String item = input.next();
System.out.print(“请输入联系人信息选项的值:”);
String val = input.next();
personDao.updatePerson(id,item, val);
}else if(“4”.equals(num)){
System.out.print(“请输入要删除联系人的姓名:”);
String name = input.next();
personDao.deletePerson(name);
}else if(“5”.equals(num)){
break;
}else{
System.out.println(“您输入不合法,请重新选择!”);
} } }else if(“3”.equals(in2)){ System.out.println(“您已经退出系统!”);System.exit(-1);}else{ System.out.println(“您输入不合法,请重新选择!”);}
第二篇:java书店管理系统源代码
Java 源代码
public class loaduser { public String user;public String password;boolean b1;loaduser(String s1,String s2){
user=s1;
password=s2;} void load(){
System.out.println(“ 书店管理销售系统”);
System.out.println(“**************************************”);System.out.println(“
1、登录系统”);System.out.println(“
2、退出系统”);
System.out.println(“**************************************”);System.out.println(“请选择:”);
int m;Scanner s=new Scanner(System.in);m=s.nextInt();
if(m==1){
for(int i=0;i<3;i++){
System.out.println(“请输入账户名和密码”);
String s3,s4;
Scanner ss=new Scanner(System.in);
s3=s.next();
s4=s.next();
if(user.equals(s3)&&password.equals(s4))b1=true;
else b1=false;
if(i==0&&b1==false)System.out.println(“用户名或密码输入错误一次,还有两次机会!”);
if(i==1&&b1==false)System.out.println(“用户名或密码输入错误两次,还有一次机会!”);
if(i==2&&b1==false){System.out.println(“三次输入错误,退出系统!”);System.exit(0);}
if(b1==true){
System.out.println(“登录成功!”);
break;} } }
if(m==2)System.exit(0);}
package manger;import java.util.ArrayList;import java.util.Scanner;import manger.vip;import System.menu;public class vipmanger { static ArrayList
vipgroup.add(new vip(“001”,“王芳”,100));
vipgroup.add(new vip(“002”,“李娜”,60));
vipgroup.add(new vip(“003”,“杨丽”,50));
vipgroup.add(new vip(“004”,“孙洁”,150));
vipgroup.add(new vip(“005”,“肖青”,300));} static void addd(){ System.out.println(“请一次输入编号,姓名,积分”);
String S1,S2;
int A;
Scanner s=new Scanner(System.in);
S1=s.next();
S2=s.next();
A=s.nextInt();
vip v1=new vip(S1,S2,A);vipgroup.add(v1);}
static void delete(){ System.out.println(“请输入要求删除的会员编号:”);String s;Scanner me=new Scanner(System.in);s=me.next();
boolean b1=true;
for(int i=0;i if(s.equals(vipgroup.get(i).ID)){vipgroup.remove(i);b1=false;} if(b1)System.out.println(“查无此会员!”);} static void correct(){ System.out.println(“请输入要修改信息的会员编号:”);String sss;Scanner s=new Scanner(System.in);sss=s.next(); boolean b1=true; for(int i=0;i if(sss.equals(vipgroup.get(i).ID)){ b1=false; System.out.println(“请输入新的姓名和积分:”); String ss1;Scanner s7=new Scanner(System.in);ss1=s7.next();vipgroup.get(i).name=ss1;int b; Scanner s8=new Scanner(System.in); b=s8.nextInt(); vipgroup.get(i).score=b;} if(b1==true)System.out.println(“查无此会员!”);} static void select(){ System.out.println(“请输入要查询的会员编号:”);String s;Scanner me=new Scanner(System.in);s=me.next(); boolean b1=true; for(int i=0;i if (s.equals(vipgroup.get(i).ID)){System.out.println(vipgroup.get(i).ID+“ ”+vipgroup.get(i).name+“ ”+vipgroup.get(i).score);b1=false;} if(b1==true)System.out.println(“查无此会员!”);} static void show(){ for(int i=0;i System.out.println(vipgroup.get(i).ID+“ ”+vipgroup.get(i).name+“ ”+vipgroup.get(i).score);} public static void exchange(String s1,int a,int b){ boolean b1=true; for(int i=0;i if(s1.equals(vipgroup.get(i).ID)) {if(vipgroup.get(i).score<(a*b))System.out.println(“积分不足,不能兑换!”); else vipgroup.get(i).score-=a*b; b1=false; } if(b1==true)System.out.println(“查无此会员,不能兑换!”);} public static void shop(String s1,int a,int b){ boolean b1=true; for(int i=0;i if(b1==true)System.out.println(“查无此会员,不能购买!”);} public static boolean start(){ menu m=new menu();m.vip(); int x;Scanner me= new Scanner(System.in);x=me.nextInt(); switch(x){ case 1:show();break; case 2:delete();break; case 3:addd();break; case 4:correct();break; case 5:select();break; case 6:return false;} return true;} } public class book { public String number; public String name; public int price; public int jf;book(String s1,String s2,int a,int b){ number=s1; name=s2; price=a; jf=b;} } package manger;import java.util.ArrayList;import java.util.Scanner;import System.menu;public class bookmanger { static ArrayList for(i=0;i return a;} public static String name(String s1){ String a = “无此书”;for(int i=0;i return a;} public static boolean start(){ menu m=new menu();m.bookmanger();int x;Scanner me= new Scanner(System.in);x=me.nextInt();switch(x){ case 1:show();break;case 2:delete();break;case 3:addd();break;case 4:return false;} return true;} } public class gift { public String number;public String caption;public int costjf;gift(String s1,String s2,int a){ number=s1;caption=s2;costjf=a;} } package manger;import java.util.ArrayList;import java.util.Scanner;import manger.vipmanger;import manger.vip;import System.menu;import manger.gift;public class giftmanger { static ArrayList giftgroup.add(new gift(“001”,“鼠标垫”,100)); giftgroup.add(new gift(“002”,“书夹子”,50)); giftgroup.add(new gift(“003”,“中性笔”,30));} static void show(){ for(int i=0;i System.out.println(“请输入要删除的礼品编号:”); String s; Scanner ss=new Scanner(System.in); s=ss.next(); boolean b1=true; for(int i=0;i if(s.equals(giftgroup.get(i).number)) {giftgroup.remove(i); b1=false; } if(b1)System.out.println(“查无此礼品!”);} static void addd(){ System.out.println(“请输入要添加的礼品编号,名称,所需积分:”); String s1,s2; int a; Scanner me=new Scanner(System.in); s1=me.next(); s2=me.next(); a=me.nextInt(); gift g1=new gift(s1,s2,a); giftgroup.add(g1);} static void exchange(){ String s1,s2,c=“无此礼品”; int a,b=0; giftmanger.show(); Scanner me=new Scanner(System.in); System.out.println(“请输入您的会员编号:”); s1=me.next(); System.out.println(“请输入您要兑换的礼品编号:”); s2=me.next(); System.out.println(“请输入您要兑换的礼品数量:”); a=me.nextInt(); boolean b1=true; for(int i=0;i {b=giftgroup.get(i).costjf; c=giftgroup.get(i).caption; b1=false; } if(b1==true)System.out.println(“查无此礼品!”); else vipmanger.exchange(s1, a, b); System.out.println(“兑换结果:”); System.out.println(“礼品名称”+“ ”+“礼品积分”+“ ”+“礼品数量”+“ ”+“消耗积分”); System.out.println(c+“ ”+b+“ ”+a+“ ”+(a*b));} public static boolean start(){ menu m=new menu(); m.gift(); int x; Scanner me= new Scanner(System.in); x=me.nextInt(); switch(x){ case 1:show();break; case 2:delete();break; case 3:addd();break; case 4:exchange();break; case 5:return false; } return true;} } public class shoping { static void shop(){ bookmanger.show();String s1,s2,s3; int a,b=0;Scanner me=new Scanner(System.in);System.out.println(“请输入您的会员编号:”);s1=me.next();System.out.println(“请输入书籍编号:”);s2=me.next();System.out.println(“请输入购买数量:”);a=me.nextInt();b=bookmanger.price(s2);s3=bookmanger.name(s2);System.out.println(“书名”+“ ”+“单价”+“ ”+“数量”+“ ”+“总价”);System.out.println(s3+“ ”+b+“ ”+a+“ ”+(a*b));vipmanger.shop(s1, a, b);} public static boolean start(){ menu m=new menu(); m.shopping(); int x; Scanner me= new Scanner(System.in); x=me.nextInt(); switch(x){ case 1:shop();break; case 2:return false; } return true;} } public class menu { void mainmenu(){ System.out.println(“ 书店管理系统”); System.out.println(“****************************”); System.out.println(“书店管理系统”); System.out.println(“ 1、会员管理”); System.out.println(“ 2、书籍管理”); System.out.println(“ 3、购物结算”); System.out.println(“ 4、积分兑换礼品”); System.out.println(“ 5、注销”); System.out.println(“****************************”); } public void vip(){ System.out.println(“书店管理系统>会员管理:”); System.out.println(“****************************”); System.out.println(“ 1、显示会员信息”); System.out.println(“ 2、删除会员”); System.out.println(“ 3、添加会员”); System.out.println(“ 4、修改会员信息”); System.out.println(“ 5、查询会员”); System.out.println(“ 6、返回上层菜单”); System.out.println(“****************************”); } public void bookmanger(){ System.out.println(“书店管理系统>书籍管理:”); System.out.println(“****************************”); System.out.println(“ 1、书籍信息查询”); System.out.println(“ 2、删除书籍”); System.out.println(“ 3、添加书籍”); System.out.println(“ 4、返回上层菜单”); System.out.println(“****************************”); } public void shopping(){ System.out.println(“书店管理系统>购物结算:”); System.out.println(“****************************”); System.out.println(“ 1、购物”); System.out.println(“ 2、返回上层菜单”); System.out.println(“****************************”); } public void gift(){ System.out.println(“书店管理系统>礼品兑换:”); System.out.println(“****************************”); System.out.println(“ 1、礼品信息”); System.out.println(“ 2、删除礼品”); System.out.println(“ 3、添加礼品”); System.out.println(“ 4、兑换礼品”); System.out.println(“ 5、返回上层菜单”); System.out.println(“****************************”); } public static void main(String[] args){ loaduser u1=new loaduser(“manger”,“416426”); u1.load();menu m1=new menu(); vipmanger vip=new vipmanger();bookmanger book=new bookmanger();giftmanger gi=new giftmanger(); while(true){ m1.mainmenu(); int x; Scanner me=new Scanner(System.in); x=me.nextInt(); switch(x){ case 1:while(vipmanger.start());break; case 2:while(bookmanger.start());break; case 3:while(shoping.start());break; case 4:while(giftmanger.start());break; case 5:u1.load(); } } } } package com.student.enty; //姓名学号语文数学英语public class Student { private String name; private int num; private double chi; private double mat; private double eng;//声明成员变量 public String getName(){ return name; } public void setName(String name){this.name = name; } public int getNum(){ return num; } public void setNum(int num){this.num = num; } public double getChi(){ return chi; } public void setChi(double chi){this.chi = chi; } public double getMat(){ return mat; } public void setMat(double mat){this.mat = mat; } public double getEng(){ return eng; } public void setEng(double eng){this.eng = eng; } } import java.io.*;import java.util.*;public class LittleProgram { static boolean isDelete = true; static boolean isFind = true; public static void main(String [] args)//主方法,程序从这里开始运行 throws IOException,NumberNotFoundException { int choice=-1; do{ LittleProgram lp = new LittleProgram(); System.out.println(); System.out.println(“t #”); System.out.println(); System.out.println(“tt通訊錄管理系统”); System.out.println(“t 请用号码插入,查找,修改,删除数据”); System.out.println(); System.out.println(“t #n”); System.out.print(“1.增加号码:n”+ “2.查找号码:n”+ “3.删除号码:n”+ “4.清除所有号码:n”+ “5.把号码全部打印到屏幕n”+ “6.把通讯录按号码排序n”+ “7.修改号码n”+ “8.统计通码讯录的总人数n”+ “9.关于作者n”+ “0.退出程序.n” + “输入:”); BufferedReader in = //从终 new BufferedReader(//端接 new InputStreamReader(System.in));//收数 String inputLine = in.readLine(); //字选 choice= Integer.valueOf(inputLine).intValue();//项; switch(choice) { case 1: {//1.增加号码 String str = lp.inputData(); lp.addData(str); System.out.println(“增加号码成功.”); timeOut(1); }break; case 2: {//2.查找号码 long find = 0; System.out.print(“请输入你要查找的号码:”); BufferedReader inn = new BufferedReader(new InputStreamReader(System.in)); String inputLi = inn.readLine(); find = Integer.valueOf(inputLi).longValue(); lp.findData(find); timeOut(2); }break; case 3: {//3.删除号码 long deleteNumber = 0; System.out.print(“请输入你想删除号码:”); BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); String inputL = bf.readLine(); deleteNumber = Integer.valueOf(inputL).longValue(); lp.deleteData(deleteNumber); if(isDelete) System.out.println(“删除号码成功!”); timeOut(1); }break; case 4: { lp.clearData();//4.清除所有号码 timeOut(1); }break; case 5: { print();//5.把号码全部打印到屏幕 timeOut(2); }break; case 6: { lp.numSort();//6.把号码按号码排序 System.out.println(“按照号码从小到大排序成功!n”+ “排序后:n”); print(); timeOut(2); }break; case 7: { lp.rewrite();//7.修改号码 timeOut(2); }break; case 8: { int count = lp.count(); System.out.println(“共有”+count+“个号码记录.”); timeOut(2); }break; case 9: { System.out.print(“tt李雪萍n”+ “tt安徽理工大學理學院n”+ “ttQQ:1154646392n”); timeOut(4); }break; }}while(choice!= 0); System.out.println(“Bye!^-^”); System.exit(0); } public String inputData()//从终端接收数据的方法,返回字符串 throws IOException,NumberFormatException { System.out.print(“请依次输入 :号码 姓名 地址 生日n” + “每项数据请用空格隔开:”); String all = “"; try{ BufferedReader in = //从终 new BufferedReader(//端接 new InputStreamReader(System.in)); //收数 String inputLine = in.readLine(); //据 StringTokenizer str = new StringTokenizer(inputLine,” “);//接收的数据用空格隔开,这个类用来提取每个字符串 long num = Integer.valueOf(str.nextToken()).longValue();//号码 String name =(String)str.nextToken(); //姓名 String add =(String)str.nextToken(); // 地址 String birth =(String)str.nextToken();//出生年月 all = String.valueOf(num)+” , “+ name +” , “+ add +” , “+ String.valueOf(birth);//把所有的数据用” , “隔开然后在连起来放进字符串all }catch(IOException e){} catch(NumberFormatException e){} return all;//返回字符串all } public void addData(String str)//增加号码的方法 throws IOException { String s1 =”“,s2=”“ ,s3= ”“; File file = new File(”c:data.txt“); if(file.exists())//如果文件data.txt存在 { try{ BufferedReader in = new BufferedReader(new FileReader(file)); while((s1=in.readLine())!=null) s2+=s1+”n“;//把文件中的每行数据全部放进一个字符串s2 s2+=str+”n“; //再把s2于形参str相连放进s2 BufferedReader in2 = //把字符 new BufferedReader(//串s2也 new StringReader(s2)); //就是原 PrintWriter out = //文件+ new PrintWriter(//形参str(新输入的一行数据) new BufferedWriter(//重新写进data.txt new FileWriter(file))); //覆盖原来的数据 while((s3=in2.readLine())!= null) { out.println(s3); } out.close(); //System.out.println(”write data true.“); }catch(IOException e){} }else{ System.err.println(”File “data” Missing!“); } } public void clearData()//清除data.txt的所有数据的方法 throws IOException { File file = new File(”c:data.txt“); if(file.exists())//如果文件在{ try{ PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(file))); out.print(”“);//在文件data.txt里写进一个空字符,所以清除了原来的内容 out.close();//关闭文件 System.out.println(”clear data true!“); }catch(IOException e){} }else{ System.err.println(”File “data” Missing!“); } } public void deleteData(long deleteNumber)//删除某条号码数据 throws IOException,FileNotFoundException { isDelete = true; try{ DataMap mp = new DataMap();//生成一个自己编写的容器 long j=0; String s1=”“,s2=”“,s3=”“; BufferedReader in = new BufferedReader(new FileReader(”c:data.txt“)); while((s1=in.readLine())!=null) { j=numberTokenizer(s1); mp.put(j,s1); } try{ if(mp.containsKey(String.valueOf(deleteNumber).toString())) { mp.remove(deleteNumber); }else throw new NumberNotFoundException(); Collection c = mp.values(); Iterator iter = c.iterator(); while(iter.hasNext()) { s1 =(String)iter.next(); s3 +=s1+”n“; } BufferedReader in2 = new BufferedReader(new StringReader(s3)); PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(”c:data.txt“))); //System.out.println(”delete No“+deleteNumber); while((s1 = in2.readLine())!=null) { out.println(s1); } out.close();}catch(NumberNotFoundException e){ isDelete = false; System.out.println(deleteNumber+” no found :(“); } }catch(IOException e){} } public long numberTokenizer(String s) throws IOException { StringTokenizer st = new StringTokenizer(s,” “); return Integer.valueOf((st.nextToken())).longValue(); } public void findData(long find)//查找数据 throws IOException,NumberNotFoundException { isFind = true; String s = ”“,findString =”“;long i;DataMap dm = new DataMap();BufferedReader in = new BufferedReader(new FileReader(”c:data.txt“)); while((s=in.readLine())!=null) { i=numberTokenizer(s); dm.put(i,s); } //in.close(); try{ if(dm.containsKey(String.valueOf(find).toString())) { findString = dm.get(find); System.out.println(”学号“+find+”学生的资料是:“); System.out.println(findString); }else throw new NumberNotFoundException(); }catch(NumberNotFoundException e){ System.out.println(find+” no found :(“); isFind = false; } } public static void print()//读取文本文件把数据打印到终端的方法 throws IOException { try{ BufferedReader in = new BufferedReader(new FileReader(”c:data.txt“)); String read = ”“; while((read = in.readLine())!=null) System.out.println(read); }catch(IOException e){} } public static void timeOut(double sec)//停顿短暂时间的一个方法完全可以不要这个功能 { double seconds = sec; long t = System.currentTimeMillis()+(int)(seconds*1000); while((System.currentTimeMillis()) ; } public void numSort()//按学号排序 throws IOException { long i = 0; String s = ”“; try{ DataArrayList dal = new DataArrayList(); BufferedReader in = new BufferedReader(new FileReader(”c:data.txt“)); while((s=in.readLine())!=null) { i=numberTokenizer(s); dal.add(i); } Collections.sort(dal); DataMap dm = new DataMap(); BufferedReader in2 = new BufferedReader(new FileReader(”c:data.txt“)); while((s=in2.readLine())!=null) { i=numberTokenizer(s); dm.put(i,s); } PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(”c:data.txt“))); Iterator it = dal.iterator(); long temp = 0; String tempStr = ”“; while(it.hasNext()) { temp = Integer.valueOf((String)it.next()).longValue(); tempStr = dm.get(temp); out.println(tempStr); } out.close(); }catch(IOException e){} } public void rewrite() throws IOException,NumberNotFoundException { try{ System.out.print(”请输入你要修改的学生号码:“); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String inputLine = in.readLine(); long num = Integer.valueOf(inputLine).longValue(); findData(num); if(isFind) { deleteData(num);System.out.print(”请重新输入该号码:“);String str = inputData(); addData(str); System.out.println(”rewrite true!“); } }catch(IOException e){} catch(NumberNotFoundException e){} } public int count() throws IOException { DataArrayList dal = new DataArrayList(); try{ String s = ”“; long i =0; BufferedReader in = new BufferedReader(new FileReader(”c:data.txt“)); while((s=in.readLine())!=null) { i=numberTokenizer(s); dal.add(i); } }catch(IOException e){} return dal.size(); } } /* * * @author RangWei * TODO 这是个写的一个容器,继承公共类HashMap * 大概的功能就相当一个数组 * */ class DataMap extends HashMap//一个存储数据的Map { public void put(long i,String str)//把学号和数据放进这个Map { //以后一个学号(key)对应的是一个人的数据(value) put(String.valueOf(i).toString(),str); } public void remove(long i)//接收学号,然后删除学号(key)和它对应的数据(value) { remove(String.valueOf(i).toString().toString()); } public String get(long i)//接收一个学号,然后返回这个key对应的value { String s = String.valueOf(i).toString(); if(!containsKey(s)) { System.err.println(”Not found Key: "+s); } return(String)get(s); } } /* * * @author RangWei * * TODO 这个类继承ArrayList * 用来按数字排序,在用号码排序时要用到它 * */ class DataArrayList extends ArrayList { public void add(long num) { String numToString = String.valueOf(num).toString(); add(numToString); } } /* * * @author RangWei * * TODO 增加的一个Exception,主要是在文件里没有要找 * 的号码就抛出 * */ class NumberNotFoundException extends Exception { public NumberNotFoundException() {} } 通讯录管理系统的设计与实现源代码 #include } } } iCount=t;} infile.close();} void Print(Student *h)//打印记录 { if(h==NULL){ cout<<“n****************************************nn”;cout<<“没有学生记录!n”;cout<<“n****************************************n”;return;} cout<<“n********************************************************************************nn”;cout<<“所有的学生:nn”;cout<<“-----------n”;cout<<“| ”< if(h==NULL){cout<<“n****************************************n”;cout<<“没有学生记录!n”;cout<<“n****************************************n”;return;} cout<<“n********************************************************************************n”;cout<<“所有学生:nn”;cout<<“-----------n”;cout<<“| ”< void Print_search(Student *h)//查询 { if(h==NULL){cout<<“n********************************************************************************n”;cout<<“没有学生记录!n”;cout<<“n****************************************n”;return;} cout<<“n********************************************************************************n”;cout<<“所查学生:nn”;cout<<“-----------n”;cout<<“| ”< { cout<<“-----------n”;cout<<“| ”< cout<<“n********************************************************************************nn”;cout<<“请输入内容:”< cout<<“n********************************************************************************n”;cout<<“[1] 增加一个学生n” <<“[2] 显示所有的学生以及他们的成绩n” <<“[3] 显示数组中平均成绩<40的学生以及他们的成绩n” <<“[4] 显示数组中学号为I的学生信息n” <<“[5] 存盘并退出n”;cout<<“********************************************************************************nn”;cout<<“请选择操作项:[1-5] ”;cin>>n;} } }第三篇:学生成绩管理系统 java源代码
第四篇:数据结构课程设计—java通讯录管理系统
第五篇:通讯录管理系统的设计与实现c++源代码