zoukankan      html  css  js  c++  java
  • Lesson_9 作业_2 工厂

    一.作业描述

    根据需要我们来模拟下面的场景:

      我们需要建立一个制造工厂,里面有很多各种各样的工人,比如:

        生产工人:可以制造原材料,加工塑形等。

        生产经理:比生产工人高级,还具有管理指挥能力。

        搬运工人:搬运货物。

        维修工人:维修生产设备(比如车床,汽车等设备)

    为了提高工厂的生产效率,厂长提出要改革工厂生产方式实施一些自动化设备。则要求

    如下:

       1 每个生产工人都必须知道使用自动化设备

      2 每个维修工人必须除了使用自动化设备外,必须还有知道维修信息化设备(如电脑)

      3 搬运工人要学会使用搬运机械提高搬运能力

      此外针对安全要求,安全部门提出每个人必须都具备基本逃生能力(后续可能会要求具有使用逃生设备的能力)

    二.代码

    View Code
      1 /************************************************************
      2 *                    Lesson_9 作业_2 -- 工厂
      3 *                         2013-01-20
      4 *                        by CocoonFan
      5 *
      6 *************************************************************
      7 *************************作业描述*****************************
      8 *
      9 *     根据需要我们来模拟下面的场景:
     10 *     我们需要建立一个制造工厂,里面有很多各种各样的工人,比如:
     11 * 生产工人:可以制造原材料,加工塑形等。
     12 * 生产经理:比生产工人高级,还具有管理指挥能力。
     13 * 搬运工人:搬运货物。
     14 * 维修工人:维修生产设备(比如车床,汽车等设备)
     15 * 为了提高工厂的生产效率,厂长提出要改革工厂生产方式实施一些自
     16 * 动化设备。则要求如下:
     17 *    1 每个生产工人都必须知道使用自动化设备
     18 *    2 每个维修工人必须除了使用自动化设备外,必须还有知道维修
     19 *      信息化设备(如电脑)
     20 *    3 搬运工人要学会使用搬运机械提高搬运能力
     21 *    此外针对安全要求,安全部门提出每个人必须都具备基本逃生能
     22 * 力(后续可能会要求具有使用逃生设备的能力)
     23 *************************************************************/
     24 
     25 public class TestFactory {
     26     public static void main(String[] args) {
     27         Worker worker = new Worker("生产工人");
     28         Manager manager = new Manager("生产经理");
     29         Porter porter = new Porter("搬运工人");
     30         Mechanics mechanics = new Mechanics("维修工人");
     31         
     32         Equipment equipment = new Equipment("搬运机械");
     33         AutomationEquipment automationEquipment = new AutomationEquipment("自动化设备");
     34         ElectricalEquipment electricalEquipment = new ElectricalEquipment("电脑");
     35         
     36         worker.escapeAbility();
     37         worker.workAbility();
     38         worker.useAutomationEquipment(automationEquipment);
     39         System.out.println();
     40         
     41         manager.workAbility();
     42         manager.otherWorkAbility();
     43         manager.escapeAbility();
     44         System.out.println();
     45         
     46         porter.workAbility();
     47         porter.useMachine(equipment);
     48         System.out.println();
     49         
     50         mechanics.useAutomationEquipment(automationEquipment);
     51         mechanics.fixElectricalEquipment(electricalEquipment);
     52         
     53     }
     54 }
     55 
     56 class Worker{
     57     private String workerKind;
     58     
     59     public Worker(String workerKind) {
     60         this.workerKind = workerKind;
     61     }
     62     
     63     
     64     public String getWorkerKind() {
     65         return workerKind;
     66     }
     67     public void setWorkerKind(String workerKind) {
     68         this.workerKind = workerKind;
     69     }
     70     
     71     //逃生能力
     72     public void escapeAbility(){
     73         System.out.println(workerKind + "还具备逃生能力");
     74     } 
     75     
     76     //制造原材料,加工塑形
     77     public void workAbility(){
     78         System.out.println(workerKind + "可以制造原材料,加工塑形等");
     79     }
     80     
     81     //使用自动化设备
     82     public void useAutomationEquipment(AutomationEquipment automationEquipment) {
     83         System.out.println(workerKind + "能使用" + automationEquipment.getEquipmentKind());
     84     }
     85     
     86 }
     87 
     88 class Manager extends Worker{
     89 
     90     public Manager(String workerKind) {
     91         super(workerKind);
     92     }
     93     
     94     //具有管理指挥能力
     95     public void otherWorkAbility(){
     96         System.out.println(super.getWorkerKind() + "具有管理指挥能力");
     97     }
     98 }
     99 
    100 class Porter extends Worker{
    101 
    102     public Porter(String workerKind) {
    103         super(workerKind);
    104     }
    105     
    106     //搬运货物
    107     @Override
    108     public void workAbility(){
    109         System.out.println(super.getWorkerKind() + "可以搬运货物");
    110     }
    111     
    112     //使用机械搬运货物
    113     public void useMachine(Equipment equipment){
    114         System.out.println(super.getWorkerKind() + "可以使用"
    115                 + equipment.getEquipmentKind() + "提高搬运能力");
    116     }
    117     
    118 }
    119 
    120 class Mechanics extends Worker{
    121 
    122     public Mechanics(String workerKind) {
    123         super(workerKind);
    124     }
    125     
    126     //维修生产设备
    127     @Override
    128     public void workAbility(){
    129         System.out.println(super.getWorkerKind() + "维修生产设备");
    130     }
    131     
    132     //维修某种电气设备
    133     public void fixElectricalEquipment(ElectricalEquipment electricalEquipment){
    134         System.out.println(super.getWorkerKind() + "能维修" + electricalEquipment.getEquipmentKind());
    135     }
    136     
    137     
    138 }
    139 class Equipment{
    140     private String equipmentKind;
    141     
    142     public Equipment(String equipmentKind) {
    143         this.equipmentKind = equipmentKind;
    144     }
    145 
    146     public String getEquipmentKind() {
    147         return equipmentKind;
    148     }
    149 
    150     public void setEquipmentKind(String equipmentKind) {
    151         this.equipmentKind = equipmentKind;
    152     }
    153     
    154 }
    155 
    156 class AutomationEquipment extends Equipment{
    157 
    158     public AutomationEquipment(String equipmentKind) {
    159         super(equipmentKind);
    160     }
    161     
    162     public void function(){
    163         System.out.println(super.getEquipmentKind() + "可以提高工作效率");
    164     }
    165     
    166 }
    167 
    168 class ElectricalEquipment extends Equipment{
    169 
    170     public ElectricalEquipment(String equipmentKind) {
    171         super(equipmentKind);
    172     }
    173     
    174 }

    三.运行结果

  • 相关阅读:
    14.9 InnoDB Disk IO and File Space Management InnoDB Disk 和文件空间管理
    haproxy web通过根跳转
    Linux_NIS+NFS+Autofs
    Linux_NIS+NFS+Autofs
    haproxy 配置心跳检查
    14.8.2 Specifying the Row Format for a Table 指定表的Row Format
    14.8.1 Overview of InnoDB Row Storage
    HTML5新增表单之color
    perl vim美化
    14.7.1 Enabling File Formats
  • 原文地址:https://www.cnblogs.com/CocoonFan/p/2869157.html
Copyright © 2011-2022 走看看