public class MediumFacade {
private CuiYuanApartment cuiyuan;
private XiXiApartment xixi;
private XiHuApartment xihu;
public MediumFacade() {
cuiyuan = new CuiYuanApartment("翠苑小区", 900, 1);
xixi = new XiXiApartment("西溪花园", 1200, 1);
xihu = new XiHuApartment("西湖小区", 2600, 1);
}
public void rentingHouse(double price) {
// 价钱合适而且有房可组
if (price >= cuiyuan.getPrice() && cuiyuan.getStatus() != 0) {
System.out.println("预订" + cuiyuan.getLocation());
cuiyuan.setStatus(0);
} else if (price >= xixi.getPrice() && xixi.getStatus() != 0) {
System.out.println("预订" + xixi.getLocation());
xixi.setStatus(0);
} else if (price >= xihu.getPrice() && xihu.getStatus() != 0) {
System.out.println("预订" + xihu.getLocation());
xihu.setStatus(0);
} else {
System.out.println("出价太低/没有房源 ...");
}
}
}
/**
* @author jifang
* @since 16/8/23 上午10:12.
*/
public class XiHuApartment {
private String location;
private double price;
private int status;
public XiHuApartment(String location, double price, int status) {
this.location = location;
this.price = price;
this.status = status;
}
public String getLocation() {
return location;
}
public double getPrice() {
return price;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
}
class XiXiApartment {
private String location;
private double price;
private int status;
public XiXiApartment(String location, double price, int status) {
this.location = location;
this.price = price;
this.status = status;
}
public String getLocation() {
return location;
}
public double getPrice() {
return price;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
}
class CuiYuanApartment {
private String location;
private double price;
private int status;
public CuiYuanApartment(String location, double price, int status) {
this.location = location;
this.price = price;
this.status = status;
}
public String getLocation() {
return location;
}
public double getPrice() {
return price;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
}
public class Client {
@Test
public void client() {
MediumFacade facade = new MediumFacade();
facade.rentingHouse(800);
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有