java课程设计——客户管理系统源代码

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Person per =list .get( i ); if ( num==per .getNum()){
showTitle(); System. out .println( per );
精心整理
System. out .println( " 是否确定删除( Y/N)? " );
String answer =input .next();
return list ;
}
privatevoid savelist(List<Person>
list ) throws FileNotFoundExceptio
n{
PrintWriter pw=newPrintWriter( newFile( INFO));
for (Person c: list ){
showTitle(); System. out .println(
per );
savelist( list );
System. out .println( " 修改成功! " );
} else {
System. out .println( " 编号不存在! " );
}
}
// 查询
publicvoid search() throws NumberFormatException,IOException{
}
}
}
public List<Person>getList()
throws NumberFormatException,IOException
{
BufferedReader br =newBufferedReader( newFileReader( file ));
String msg=null ;
System. out .println( "\t[4] 退出 " );
System. out .println( "\t 请选择查询编号 " ); return input .nextInt();
} }
3.实际操作类( classFileOperate):
package 客户管理系统 ; import import import
System. out .println( " 【6】退出 " );
System. out .println( "***********************************"
);
System. out .print( " 请选择操作: " ); return input .nextInt(); }
List<Person> list =newArrayList<Person>();
while (( msg=br .readLine())!= null ){
String arr []= msg.split( "\t" );
int num=Integer. parseInt ( arr [0]);
String name=arr [1];
String address =arr [2];
String sex =arr [3];
Person person =newPerson( num, name, address , sex );
list .add( person );
}
br .close();
精心整理
boolean flag =true ; List<Person> list =getList(); if ( list .size()!=0){
while ( flag ){ int slt =newMenu().subMenu(); switch ( slt ){ case 1:
System. out .print( "\t 请输入编号: " ); findId( input .nextInt()); break ; case 2:
System. out .println( " 请输入性别: " ); String sex =input .next(); Per百度文库on person =newPerson( num, name, address , sex ); List<Person> list =getList(); list .add( person ); savelist( list );
List<Person> list =getList(); for ( int i =0; i <list .size(); i ++){ Person per =list .get( i ); if ( num==per .getNum()){
return i ; } } return -1; } // 增加 publicvoid insert() throws NumberFormatException,IOException{ System. out .println( " 请输入编号: " ); int num=input .nextInt(); int index =getper( num); if ( index !=-1){
if ( "Y" .equalsIgnoreCase( answer )){ list .remove( i );
savelist( list );
System. out .println( " 删除成功 !" );
}
flag =true ;
break ; }
}
if (! flag ){
System. out .println( " 该客户不存在! " );
publicint subMenu(){
System. out .println( "\t 【查询客户】 " );
System. out .println( "\t[1] 按客户编号查询 " );
System. out .println( "\t[2] 按客户姓名查询 " );
System. out .println( "\t[3] 按地址查询 " );
address ,String
sex ){
精心整理
} public return }
}
StringtoString(){ "\t" +num+"\t" +name+"\t"
+address +"\t"
+sex ;
2.菜单类 (classMenu):
package 客户管理系统 ; import
publicclass Menu{ Scanner input =newScanner(System. in );
System. out .println( " 【1】增加 " );
System. out .println( " 【2】删除 " );
System. out .println( " 【3】修改 " );
System. out .println( System. out .println(
" 【4】查询 " ); " 【5】浏览 " );
System. out .println( " 新增成功! " ); } } // 删除 publicvoid delete() throws NumberFormatException,IOException{ System. out .println( " 请输入要删除的编号: " ); int num=input .nextInt(); List<Person> list =getList(); boolean flag =false ; for ( int i =0; i <list .size(); i ++){
String sex =input .next();
List<Person> list =getList(); Person per =list .get( Id );
per .setName( name);
per .setAddress( address );
per .setSex( sex );
pw.format( "%d\t%s\t%s\t%s\t\r\n" dress(), c .getSex());
} pw.close();
, c.getNum(), c.getName(), c .getAd
精心整理
} publicint getper( int num) throws NumberFormatException,IOException{
Scanner input =newScanner(System. in );
public FileOperate(){
if (! file .exists()){
try {
file .createNewFile();
} catch (IOException e){
e.printStackTrace();
}
}
// 修改
publicvoid update() throws NumberFormatException,IOException{
shoAll();
System. out .println( " 请输入编号: \n" );
int num=input .nextInt();
int Id =getper( num); if ( Id !=-1){
public Menu(){}
publicint showMenu(){
System. out .println( "***********************************"
);
System. out .println( System. out .println(
" 客户管理系统 " ); "===================================" );
完整代码:
精心整理
1.客户类( classperson):
package 客户管理系统 ; publicclass Person{ privateint num; private String name; private String address ; private String sex ; public Person(){} public Person( int num,String name,String this . num=num; this . name=name; this . address =address ; this . sex =sex ; } publicvoid setNum( int num){ this . num=num; } publicint getNum(){ return num; } publicvoid setName(String name){ this . name=name; } public StringgetName(){ return name; } publicvoid setAddress(String address ){ this . address =address ; } public StringgetAddress(){ return address ; } publicvoid setSex(String sex ){ this . sex =sex ; } public StringgetSex(){ return sex ;
System. out .println( " 此编号已存在! " );} else {
System. out .println( " 请输入姓名: " ); String name=input .next();
System. out .println( " 请输入地址: " ); String address =input .next();
System. out .println( " 请输入姓名 :" );
String name=input .next();
System. out .println( " 请输入地址 :" );
String address =input .next();
System. out .println( " 请输入性别 :" );
精心整理
import
import
import
import
import
import java.util.Scanner;
publicclass FileOperate{
privatestatic String INFO="D:/info.dat" ;
File file =newFile( INFO);
相关文档
最新文档