zoukankan      html  css  js  c++  java
  • Spring案例--打印机

    目录:

     

    1.applicationContext.xml配置文件

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans.xsd">
        <!--注入bean
            id相当于当前bean唯一标识
            class是bean 的全路径
            property注入bean中的属性         必须封装
        -->
        <!--注入墨盒-->
        <bean id="colorInk" class="cn.spring.print.ink.ColorInk"></bean>
        <bean id="blackWhiteInk" class="cn.spring.print.ink.BlackWhiteInk"></bean>
        <!--注入纸张-->
        <bean id="a4Paper" class="cn.spring.print.paper.A4Paper"></bean>
        <bean id="b5Paper" class="cn.spring.print.paper.B5Paper"></bean>
        <!--打印机-->
        <bean id="printer" class="cn.spring.print.printer.Printer">
            <!--将墨盒纸张组合起来-->
            <property name="paper" ref="b5Paper"></property>
            <property name="ink" ref="colorInk"></property>
        </bean>
    </beans>

    2.墨盒接口  Ink

        

     3.黑白墨盒实现类 BlackWhiteInk

         

     4.彩色墨盒实现类 ColorInk

        

     5.纸张接口  Paper

       

     6. A4纸张实现类   A4Paper

       

     7. B5纸张实现类  B5Paper

       

    8.   打印机类 Printer

       

     9.  测试类  PrintTest

       

  • 相关阅读:
    android中的Cursor类
    设计模式之UML类图的常见关系(一)
    关于form 上传文件时的小问题
    Javascript中最常用的61段经典代码
    自我提升mysql
    为mysql在表的某一位置增加一列
    由<a>标签的onclick影出来的问题
    第一博客
    异常的出理
    2016.7.17内部类
  • 原文地址:https://www.cnblogs.com/Zzzzn/p/11731519.html
Copyright © 2011-2022 走看看