定义一个雇员类Employee,包括属性:姓名,工号,年龄,工资。
package java3;
import java.io.*;
import java.util.*;
public class Employee {
public String name;
public String ID;
public int age;
public String salary;
public Employee(String name,String ID,int age,String salary){
this.name=name ;
this.ID=ID;
this.age=age;
this.salary=salary;
}
public String getID() {
return ID;
}
public void setID(String ID) {
this.ID=ID;
}
public void show() throws Exception {
String str=ID;
String age=str.substring(8,10);
String randnum=str.substring(10,13);
if(age.equals("00")) {
System.out.println("性别:男");
}
else System.out.println("性别:女");
System.out.println("随机序列码"+randnum);
/* int n=-1;
byte[] b=new byte[20];
FileInputStream fis =new FileInputStream(str);
FileInputStream fis1 =new FileInputStream(str);
while((n=(b,9,2))!=-1) {
String age1=(n);
int a= n;
if(a==00) {
("性别:男");
}
("性别:女");
("性别:"+ age1);
}
while((n=(b,11,3))!=-1) {
String randnum=(n);
("随机序列码:" +randnum);
}
*/
}
public static void main(String []args) throws Exception {
Scanner input =new Scanner(System.in);
StringBuffer str0=new StringBuffer();
String str1=" ";
System.out.println("pleaess input rznianfen yyyyMMdd\n");
str1=input.nextLine();
str0.append(str1);
System.out.println("pleaess input sex 00or01\n");
str1=input.nextLine();
str0.append(str1);
System.out.println("pleaess input three bits rand number without all 0 or 1\n");
str1=input.nextLine();
str0.append(str1);
String str2=new String(str0);
Employee em =new Employee("zengtao",str2,22,"5800");
System.out.println("从工号提取入职日期(Date),提取性别,提取随机序列码");
em.show();
System.out.println();
System.out.println("根据输入的入职日期(Date)、性别,生成随机序列码,组成工号:。");
String str= em.getID();
System.out.println(str);
}
}