首页 > 其他 > 详细

2013华为第五届编程大赛 成都初赛题目和解答

时间:2014-04-17 17:14:32      阅读:537      评论:0      收藏:0      [点我收藏+]
package AbstractFac;

public class AbstractFactory {
 
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Sender demo=new SendMailFactory().produce();
		demo.Send();
		demo=new SendSmsFactory().produce();
		demo.Send();
	}

}
interface Sender {  
    public void Send();  
}  
class MailSender implements Sender {  
    @Override  
    public void Send() {  
        System.out.println("this is mail sender!");  
    }  
}  

class SmsSender implements Sender {  
	  
    @Override  
    public void Send() {  
        System.out.println("this is sms sender!");  
    }  
} 
interface Provider {  
    public Sender produce();  
}

class SendMailFactory implements Provider {  
    
    @Override  
    public Sender produce(){  
        return new MailSender();  
    }  
}
class SendSmsFactory implements Provider{  
	  
    @Override  
    public Sender produce() {  
        return new SmsSender();  
    }  
} 

2013华为第五届编程大赛 成都初赛题目和解答,布布扣,bubuko.com

2013华为第五届编程大赛 成都初赛题目和解答

原文:http://blog.csdn.net/simon_xia_uestc/article/details/23933507

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!