(完整版)职工信息管理系统java源代码

  • 格式:doc
  • 大小:73.51 KB
  • 文档页数:7

下载文档原格式

  / 7
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

package exercise;

import java.io.*;

class staffInfo //职工类

{

public String name;

public String num;

public String sex;

public String age;

public String record;

public String position;

public String wanges;

public String tel;

public String addr;

}

public class StaffInfomation //实现部分

{

public static void main(final String[] args) throws IOException {

staffInfo staffOne[]=new staffInfo[100];

for(int j=0;j<100;j++)

staffOne[j] = new staffInfo();

final ways staffTwo=new ways();

staffTwo.caidan(staffOne);

staffTwo.creat(staffOne);

staffTwo.output(staffOne);

staffTwo.search(staffOne);

staffTwo.delete(staffOne);

}

}

class ways //方法类,主要实现职工信息的建立,显示,查找,删除,信息的保存与读取;这个类是整个程序的操作类。

{

public String recordkey;

public int i=0;//i用来存放职工的人数

public String filename="Infomation.txt";

BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));

void caidan(staffInfo staffOne[]) throws IOException

{

final BufferedReader buf=new BufferedReader(new InputStreamReader(System.in)); //此处是JAVA语言中输入数据的基本格式,功

能有如C中的scanf函数

int choice;

do{

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("┃★★★ 6.安全退出系统★★★┃");

System.out.println("┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛");

System.out.print(" 请输入您需要的功能代号(1--6):");

choice=Integer.parseInt(buf.readLine());

switch(choice){

case 1:creat(staffOne);break;

case 2:output(staffOne);break;

case 3:search(staffOne);break;

case 4:delete(staffOne);break;

case 5:read(staffOne);break;

case 6:save(staffOne);break;

}

}

while(choice!=0);

}

void creat(staffInfo staffOne[]) throws IOException

{

final BufferedReader buf=new BufferedReader(new

InputStreamReader(System.in));

System.out.print("请输入职工信息(以0结束)\n");

System.out.print("姓名:");

staffOne[i].name=buf.readLine(); //用数组staffOne[i]来暂存职工的相

关信息

while(staffOne[i]pareTo("0")!=0) //用compareTo方法确定

判定是否应该写入新信息

{

System.out.print("工号:");

staffOne[i].num=buf.readLine();

System.out.print("性别:");

staffOne[i].sex=buf.readLine();

System.out.print("年龄:");

staffOne[i].age=buf.readLine();

System.out.print("学历:");

staffOne[i].record=buf.readLine();

System.out.print("职位:");

staffOne[i].position=buf.readLine();

System.out.print("工资:");

staffOne[i].wanges=buf.readLine();

System.out.print("电话:");

staffOne[i].tel=buf.readLine();

System.out.print("住址:");

staffOne[i].addr=buf.readLine();

i++;

System.out.println("请输入下一个职工信息:");

staffOne[i].name=buf.readLine();

}

}

void output(staffInfo staffOne[]) throws IOException //这里是实现“输

出(预览)职工信息”output的模块

{

for(int j=0;j

{

if(i!=0)

{

System.out.println("---------------------------------------------

---------------------------------------------------");

System.out.println(" *职工信息表* ");

System.out.println("---------------------------------------------