项目三:开发团队调度软件

项目三:开发团队调度软件

知识点:

  1. 类的继承和多态
  2. 对象的值传递、接口
  3. static 和 final 修饰符
  4. 特殊类的使用:包装类、抽象类、内部类
  5. 异常处理

service层

Date

package project3.service;

public class Data {
   
    public static final int EMPLOYEE = 10;
    public static final int PROGRAMMER = 11;
    public static final int DESIGNER = 12;
    public static final int ARCHITECT = 13;

    public static final int PC = 21;
    public static final int NOTEBOOK = 22;
    public static final int PRINTER = 23;

    //Employee  :  10, id, name, age, salary
    //Programmer:  11, id, name, age, salary
    //Designer  :  12, id, name, age, salary, bonus
    //Architect :  13, id, name, age, salary, bonus, stock
    public static final String[][] EMPLOYEES = {
   
            {
   "10", "1", "马云", "22", "3000"},
            {
   "13", "2", "马化腾", "32", "18000", "15000", "2000"},
            {
   "11", "3", "李彦宏", "23", "7000"},
            {
   "11", "4", "刘强东", "24", "7300"},
            {
   "12", "5", "雷军", "28", "10000", "5000"},
            {
   "11", "6", "任志强", "22", "6800"},
            {
   "12", "7", "柳传志", "29", "10800","5200"},
            {
   "13", "8", "杨元庆", "30", "19800", "15000", "2500"},
            {
   "12", "9", "史玉柱", "26", "9800", "5500"},
            {
   "11", "10", "丁磊", "21", "6600"},
            {
   "11", "11", "张朝阳", "25", "7100"},
            {
   "12", "12", "杨致远", "27", "9600", "4800"}
    };

    //如下的EQIPMENTS数组与上面的EMPLOYEES数组元素一一对应
    //PC      :21, model, display
    //NoteBook:22, model, price
    //Printer :23, type, name
    public static final String[][] EQIPMENTS = {
   
            {
   },
            {
   "22", "联想T4", "6000"},
            {
   "21", "戴尔", "NEC17寸"},
            {
   "21", "戴尔", "三星 17寸"},
            {
   "23", "激光", "佳能 2900"},
            {
   "21", "华硕", "三星 17寸"},
            {
   "21", "华硕", "三星 17寸"},
            {
   "23", "针式", "爱普生20K"},
            {
   "22", "惠普m6", "5800"},
            {
   "21", "戴尔", "NEC 17寸"},
            {
   "21", "华硕","三星 17寸"},
            {
   "22", "惠普m6", "5800"}
    };
}


NameListService

package project3.service;

import project3.domain.*;

import static project3.service.Data.*;

public class NameListService {
   

    private Employee[] employees;

    public NameListService() {
   
        employees=new Employee[EMPLOYEES.length];
        //
        for (int i = 0; i <employees.length ; i++) {
   
            //获取通用属性
            Equipment equipment;
            int type = Integer.parseInt (EMPLOYEES[i][0]);
            int id = Integer.parseInt (EMPLOYEES[i][1]);
            String name=EMPLOYEES[i][2];
            int age = Integer.parseInt (EMPLOYEES[i][3]);
            double salary = Double.parseDouble (EMPLOYEES[i][4]);
          switch (type){
   
              case EMPLOYEE:
                  employees[i]=new Employee (id,name,age,salary);
                  break;
              case  PROGRAMMER:
                   equipment=craetEquipment(i);
                  employees[i]=new Programmer (id,name,age,salary,equipment);
                  break;
              case DESIGNER:
                  equipment=craetEquipment(i);
                  double bonus = Double.parseDouble (EMPLOYEES[i][5]);
                  employees[i]=new Designer (id,name,age,salary,equipment,bonus);
                  break;
              case ARCHITECT:
                  equipment=craetEquipment(i);
                  double bonus2 = Double.parseDouble (EMPLOYEES[i][5]);
                 int stock=Integer.parseInt (EMPLOYEES[i][6]);
                  employees[i]=new Architect (id,name,age,salary,equipment,bonus2,stock);
                  break;
          }
        }


    }

    private Equipment craetEquipment(int index) {
   
        int  type = Integer.parseInt (EQIPMENTS[index][0]);
        String model = EQIPMENTS[index][1];
        String display = EQIPMENTS[index][2];
        switch (type){
   
            case PC:
                return  new PC (model,display);
            case NOTEBOOK:
                double price = Double.parseDouble (EQIPMENTS[index][2]);
                return new NoteBook (model
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值