码迷,mamicode.com
首页 > 编程语言 > 详细

外观模式小程序JAVA源代码

时间:2016-07-13 14:07:40      阅读:286      评论:0      收藏:0      [点我收藏+]

标签:源代码   charge   public   amount   return   

public class CheckWord {
	public final int basicAmount=85;
	String advertisement;
	int amount;
	public CheckWord(String advertisement){
		this.advertisement=advertisement;
	}
	public void setChargeAmount(){
		amount=advertisement.length()+basicAmount;
	}
	public int getAmount(){
		return amount;
	}
}
public class Charge {
	public final int basicCharge=12;
	CheckWord checkWord;
	Charge(CheckWord checkWord){
		this.checkWord=checkWord;
	}
	public void giveCharge(){
		int charge=checkWord.getAmount()+basicCharge;
		System.out.println("广告费用:"+charge+"元");
	}
}

public class TypeSeting {

String advertisement;

public TypeSeting(String advertisement){

this.advertisement=advertisement;

}

public void typeSeting(){

System.out.println("广告排版模式:");

System.out.println("********");

System.out.println(advertisement);

System.out.println("********");

}

}

public class ClientServerFacade {

private CheckWord checkWord;

private Charge charge;

private TypeSeting typeSeting;

String advertisement;

public ClientServerFacade(String advertisement){

this.advertisement=advertisement;

checkWord=new CheckWord(advertisement);

charge=new Charge(checkWord);

typeSeting=new TypeSeting(advertisement);

}

public void doAdvertisement(){

checkWord.setChargeAmount();

charge.giveCharge();

typeSeting.typeSeting();

}

}

public class Application {

public static void main(String[] args) {

ClientServerFacade clientServerFacade;

String clinetAdvertisement="月光电脑,价格6356元,联系电话:1234567";

clientServerFacade = new ClientServerFacade(clinetAdvertisement);

clientServerFacade.doAdvertisement();

}

}


本文出自 “技术的秘密-刘聪聪的创作” 博客,请务必保留此出处http://liucongcong.blog.51cto.com/11527480/1826006

外观模式小程序JAVA源代码

标签:源代码   charge   public   amount   return   

原文地址:http://liucongcong.blog.51cto.com/11527480/1826006

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!