*生成10个员工对象,存储到ArrayList中,找出所有在2018年1月1号之前入职的员工,并显示;将所有2019年1月1日之后入职的员工删除。

2、在第一题的基础上,生成10个员工对象,存储到ArrayList中,找出所有在2018年1月1号之前入职的员工,并显示;将所有2019年1月1日之后入职的员工删除。

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  String getName() {
		return name;
	}
	public void setName(String name) {
		this.name=name;
	}
	public int getAge() {
		return age;
	}
	public void setAge(int age) {
		this.age=age;
	}
	
	public  String getSalary() {
		return salary;
	}
	public void setSalary(String salary) {
		this.salary=salary;
	}
	
	public  String toString () {
		String mess = " 姓名:" +getName()+" 年龄:"+getAge()+ " ID:"+getID()+ "薪水:"+getSalary() ;
		 return mess;
	}
	
	public int show() {
		
		String str=ID;
		
		String ymd=str.substring(0,8);

			int c=Integer.parseInt(ymd);
		return c;
		/*  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);
*/
      
		
	}
	
	
	public static void main(String []args) throws Exception {
		Scanner input =new Scanner(System.in); 
		ArrayList<Employee> arraylist=new ArrayList<Employee>();
		Employee em1 =new Employee("zengtao","2017010100222",22,"5800");
		Employee em2 =new Employee("zengtao1","2017010100223",22,"5800");
		Employee em3 =new Employee("zengtao2","2019010100232",22,"5800"); 
		Employee em4 =new Employee("zengtao3","2019010100256",22,"5800");
		Employee em5 =new Employee("zengtao4","2019010100256",22,"5800");
		Employee em6 =new Employee("zengtao5","2019010100256",22,"5800");
		Employee em7 =new Employee("zengtao6","2020010100289",22,"5800");
		Employee em8 =new Employee("zengtao7","2019010200200",22,"5800");
		Employee em9 =new Employee("zengtao8","2011010100212",22,"5800");
		Employee em  =new Employee("zengtao9","1999010100222",22,"5800");
		em.toString();
	  //  int n=em.show();
		//System.out.println(em.show());
		arraylist.add(em);
		arraylist.add(em1);
		arraylist.add(em2);
		arraylist.add(em3);
		arraylist.add(em4);
		arraylist.add(em5);
		arraylist.add(em6);
		arraylist.add(em7);
		arraylist.add(em8);
		arraylist.add(em9);
		System.out.println("test");
	
		for(int i=0;i<arraylist.size()&&arraylist.get(i).show()<20180101;i++) {
			System.out.println(arraylist.get(i));
			
		}
		
		for(int i=0;i<arraylist.size()&&arraylist.get(i).show()>2019;i++) {
			arraylist.remove(i);
		}
		
		/*	
		
		Iterator it = arraylist.iterator();
		while(it.hasNext()) {
			if(n<20180101)  System.out.println(it.next());
		}
		
		System.out.println("test");
	
		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);*/
		
	}

}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值