package com.lovecoding.day11.homework;

public class Test {

    public static void main(String[] args) {

        //创建一个员工
        Employee[] employees = new Employee[Data.EMPLOYEES.length];

        //初始化
        for (int i = 0; i < employees.length; i++) {

            //编号
            String number = Data.EMPLOYEES[i][0];
            //转换
            int num = Integer.parseInt(number);

            switch (num){
                case Data.EMPLOYEE:
                    int empId =Integer.parseInt(Data.EMPLOYEES[i][1]);
                    String empName = Data.EMPLOYEES[i][2];
                    int empAge = Integer.parseInt(Data.EMPLOYEES[i][3]);
                    Double empSalary = Double.parseDouble(Data.EMPLOYEES[i][4]);
                    //初始化对象
                    employees[i] = new Employee(empId,empName,empAge,empSalary);
                    break;
                case Data.PROGRAMMER:
                    int proId =Integer.parseInt(Data.EMPLOYEES[i][1]);
                    String proName = Data.EMPLOYEES[i][2];
                    int proAge = Integer.parseInt(Data.EMPLOYEES[i][3]);
                    Double prosSalary = Double.parseDouble(Data.EMPLOYEES[i][4]);
                    //初始化对象
                    employees[i] = new Programmer(proId,proName,proAge,prosSalary);
                    break;
                case Data.DESIGNER:
                    int desId =Integer.parseInt(Data.EMPLOYEES[i][1]);
                    String desName = Data.EMPLOYEES[i][2];
                    int desAge = Integer.parseInt(Data.EMPLOYEES[i][3]);
                    Double desSalary = Double.parseDouble(Data.EMPLOYEES[i][4]);
                    Double bonus = Double.parseDouble(Data.EMPLOYEES[i][5]);
                    //初始化对象
                    employees[i] = new Designer(desId,desName,desAge,desSalary,bonus);
                    break;

                case Data.ARCHITECT:
                    int arcId =Integer.parseInt(Data.EMPLOYEES[i][1]);
                    String arcName = Data.EMPLOYEES[i][2];
                    int arcAge = Integer.parseInt(Data.EMPLOYEES[i][3]);
                    Double arcSalary = Double.parseDouble(Data.EMPLOYEES[i][4]);
                    Double arcBonus = Double.parseDouble(Data.EMPLOYEES[i][5]);
                    Integer stock = Integer.parseInt(Data.EMPLOYEES[i][6]);
                    //初始化对象
                    employees[i] = new Architect(arcId,arcName,arcAge,arcSalary,arcBonus,stock);
                    break;
            }
        }

        //遍历
        for (Employee employee : employees) {
            System.out.println(employee);
        }


    }
}
