Skip to content

codeicu/design-pattern-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

使用策略模式+工厂模式+模版模式 重构多个if-else代码

    public void pay(String payType) {
        switch (payType) {
            case "wechat":
                System.out.println("wc pay");
                break;
            case "alipay":
                System.out.println("ali pay");
                break;
            case "bank card":
                System.out.println("bank pay");
                break;
            case "cash":
                System.out.println("cash");
                break;
            default:
                System.out.println("error");
        }
    }

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published