//villaBuilder.javapackage cn.campsg.java.experiment.entity;import java.util.Date;publicclassVillaBuilderextendsBuilder{@OverridepublicbooleanbuildBase(Date endDate){
Date date=newDate();long result =(date.getTime()-endDate.getTime())/(24*60*60*1000)+5;if(result>=0){
System.out.println("已完成欧式风格的别墅地基建设!");returntrue;}else{
System.out.println("没有在计划完工时间内完成办别墅的基础建设,需要重新评估!");returnfalse;}}@OverridepublicvoidbuildBody(){
System.out.println("开始进行欧式风格的别墅主体建设……!");}}
//OfficeBuilder.javapackage cn.campsg.java.experiment.entity;import java.util.Date;publicclassOfficeBuilderextendsBuilder{@OverridepublicbooleanbuildBase(Date endDate){
Date date =newDate();if(date.compareTo(endDate)<0){
System.out.println("没有在计划完工时间内完成办公楼的基础建设,需要重新评估!");returnfalse;}else{
System.out.println("已完成商务办公楼的基础建设!");returntrue;}}@OverridepublicvoidbuildBody(){
System.out.println("开始商务办公楼的主体房屋建设……!");}}