plasticproxy.java

来自「《深入浅出设计模式》的完整源代码」· Java 代码 · 共 38 行

JAVA
38
字号

//Title:        UsingPlastic
//Version:
//Copyright:    Copyright (c) 1999
//Author:       T-Kiang Tan
//Company:      University of Chicago: CSPP 523
//Description:  Demo.
package UsingPlastic;

import java.util.*; //Using ArrayList and HashTable

public class PlasticProxy implements PlasticProxyInterface
{

    ArrayList list;
    String[] card_types;
    public PlasticProxy(String[] cardTypes)
    {
        card_types = cardTypes;
        list = new ArrayList(card_types.length);
    }
    public String getApproval(String card_type)
    {
        System.out.println("****PlasticProxy: Connecting to " + card_type);
        Plastic plastic= new Plastic(card_type);
        System.out.println("****PlasticProxy: " + plastic.initialize());
        System.out.println("****PlasticProxy: Requesting for approval from " + card_type);

        System.out.println("****PlasticProxy: " + plastic.getApproval(card_type));
        return("Transaction has been approved");
    }
    public String initialize()
    {
        System.out.println("****PlasticProxy: Initializing proxy. done only once");
        return(new String("PlasticProxy is initialized"));
    }

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?