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 ("Advertising Cost:" +charge+ "Yuan");}}
public class Typeseting {
String advertisement;
Public typeseting (String advertisement) {
This.advertisement=advertisement;
}
public void typeseting () {
SYSTEM.OUT.PRINTLN ("Ad typesetting mode:");
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= "Moonlight Computer, Price 6356 yuan, tel: 1234567";
Clientserverfacade = new Clientserverfacade (clinetadvertisement);
Clientserverfacade.doadvertisement ();
}
}
This article is from the "Secrets of Technology-Liu Congcong creation" blog, make sure to keep this source http://liucongcong.blog.51cto.com/11527480/1826006
Appearance Mode applet Java source code