java 考勤_java,添加一个类,显示考勤信息的。

展开全部

public class Test06 {

static List list_Student_Status = new ArrayList();

static List list_Student = new ArrayList();

static List list_Studus = new ArrayList();

static Scanner scanner = new Scanner(System.in);

public Test06() {

list_Studus.add(new Status("001", "病假32313133353236313431303231363533e59b9ee7ad9431333335326237"));

list_Studus.add(new Status("002", "产假"));

list_Studus.add(new Status("003", "事假"));

list_Studus.add(new Status("004", "婚假"));

list_Student.add(new Student("001", "张三"));

list_Student.add(new Student("002", "李四"));

list_Student.add(new Student("003", "王五"));

list_Student.add(new Student("004", "刘杰"));

list_Student.add(new Student("005", "陈朋"));

list_Student.add(new Student("006", "赵明明"));

list_Student.add(new Student("007", "罗四海"));

list_Student.add(new Student("008", "谢一刀"));

list_Student_Status.add(new Student_Status("001", list_Student.get(0),

list_Studus.get(0)));

list_Student_Status.add(new Student_Status("002", list_Student.get(1),

list_Studus.get(0)));

list_Student_Status.add(new Student_Status("003", list_Student.get(2),

list_Studus.get(1)));

list_Student_Status.add(new Student_Status("004", list_Student.get(3),

list_Studus.get(0)));

list_Student_Status.add(new Student_Status("005", list_Student.get(4),

list_Studus.get(2)));

list_Student_Status.add(new Student_Status("006", list_Student.get(5),

list_Studus.get(0)));

list_Student_Status.add(new Student_Status("007", list_Student.get(6),

list_Studus.get(3)));

list_Student_Status.add(new Student_Status("008", list_Student.get(7),

list_Studus.get(0)));

}

public static void main(String[] args) {

new Test06();

showHelp();

doMothed();

}

public static void doMothed() {

System.out.println("请选择你要操作的类型  1-按学号查询考勤  2-按考勤态度id杳学生");

System.out.println("请输入...");

int num = scanner.nextInt();

switch (num) {

case 1:

Find_1();

break;

case 2:

Find_2();

break;

default:

showHelp();

break;

}

doMothed();

}

public static void Find_2() {

System.out.println("请输考勤类型代号:");

String ids2 = scanner.next();

List list_temp = findStudentsByStatusID(ids2);

System.out.println("当前请  " + findByStatusID(ids2).status + " 的人员有:");

for (Student student : list_temp) {

System.out.println(student.getName());

}

}

public static void Find_1() {

System.out.println("请输入学生学号:");

String ids = scanner.next();

List list_ss = GetByStudentID(ids);

System.out.println("当前学生为:  " + FindByid(ids).getName());

for (Student_Status student_Status : list_ss) {

System.out.println("时间: " + student_Status.getDate() + "    姓名: "

+ student_Status.getStudent().getName() + "  事由: "

+ student_Status.getStatus().status);

}

}

public static void showHelp() {

System.out.println("          学生信息列表");

System.out.println("********************************");

System.out.println("ID             姓名");

for (Student student : list_Student) {

System.out.println(student.getId() + "            "

+ student.getName());

}

System.out.println("********************************");

System.out.println("考勤状态表");

System.out.println("********************************");

System.out.println("ID             状态");

for (Status status : list_Studus) {

System.out.println(status.id + "            " + status.status);

}

System.out.println("********************************");

}

public static Status findByStatusID(String ids) {

for (Status status : list_Studus) {

if (status.id.equals(ids))

return status;

}

return null;

}

public static Student FindByid(String id) {

for (Student ss : list_Student) {

if (ss.getId().equals(id)) {

return ss;

}

}

return null;

}

// 添加考勤

public void Add_Student_Status(Student_Status ss) {

list_Student_Status.add(ss);

}

// 按考勤类型查人员

public static List findStudentsByStatusID(String id) {

List list = new ArrayList();

for (Student_Status ss : list_Student_Status) {

if (ss.getStatus().id.equals(id)) {

list.add(ss.getStudent());

}

}

return list;

}

// 按学号查询考勤

public static List GetByStudentID(String id) {

Student student = FindByid(id);

return student.getStudent_Status();

}

// 学生对象

class Student {

String id;

String name;

public Student(String id, String name) {

this.name = name;

this.id = id;

}

public String getId() {

return id;

}

public String getName() {

return name;

}

public List getStudent_Status() {

List list1 = new ArrayList();

for (Student_Status ss : list_Student_Status) {

if (ss.getStudent().getId().equals(getId())) {

list1.add(ss);

}

}

return list1;

}

}

// 考勤对象

class Status {

String id;

String status;

public Status(String id, String status) {

this.status = status;

this.id = id;

}

}

class Student_Status {

String id;

Date date;

Student student;

Status status;

public Student_Status(String id, Student student, Status status) {

this.id = id;

this.date = new Date();

this.student = student;

this.status = status;

}

public String getId() {

return id;

}

public Date getDate() {

return date;

}

public Student getStudent() {

return student;

}

public Status getStatus() {

return status;

}

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值