Moncler Outlet

Ответить

Код подтверждения
Введите код в точности так, как вы его видите. Регистр символов не имеет значения.
Смайлики
:D :) :( :o :shock: :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen:
BBCode ВКЛЮЧЁН
[img] ВКЛЮЧЁН
[flash] ВЫКЛЮЧЕН
[url] ВКЛЮЧЁН
Смайлики ВКЛЮЧЕНЫ
Обзор темы
   

Развернуть Обзор темы: Moncler Outlet

Moncler Outlet

Сообщение werew301459 » Пт мар 23, 2012 8:23 am

?????????????????????????????????????????????????????????
?1?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
?2???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????“????”,Moncler Outlet??????????“????”??????????????????????????“????”????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
?3??????????????????????????????????????????????????值????值??????????????????????????????????????????????????????????值???????????????????????????????值?????????????????????????????????????????????????????????????????????????????????????????????????????????????
?????????????????????????????????????????????????7k???????????????????????????
???????????????????????似??????????????“??????????”?????????????????????????????????????word??格???????????????????????????????????????????????????????????????????????????????????
???“??????????”?????????????????????????????????????????????? ?????????“????????????????????????????????”????“???????”?“????????”????????7k?????????????“??????????”??????????????1w?????????“??????????”??????????????????????????????????????????????“??????????”?????????????????????????????????????????????????????????????????????????????????
?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????格??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
????? ???????????????????????????????????0??????????????????????????????????????格??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
???”??????????“????
??????????
??????(???)
-->
???????????????????????????
??????
??????
????0.6?/ ??????????????
????0.1?/ ?
????5?/ M
??????
?????????20???????60???????????0.5?/?????
?????????10???????200??????????0.1?/????
?????????20??????50M??????????3?/M ???
????????????????(????????)???????????????????????????????????????????
??????
??????????2?/ ?
????0.4?/ ??????????????
????0.1?/ ?
????3?/ M
??????
??1 ??????100????????????????
??????750???????????0.3?/ ?????
??????200??????????0.1?/ ????
??????100M???????????1?/ M???
??2 ??????200????????????????
??????2000???????????0.2?/ ?????
??????500??????????0.1?/ ????
??????300M???????????0.5?/ M???
??????????????????????????????????
???????????????????????????60??
???????200????????50M??????????
???????????????
???????VIP??????????????????200?
????????200????????100M?????????
?????VIP???????????????????????
?????
?????????????1?10??????????????????
?????????????1?10??????????
??????????????????50K?100K?200K?500K?1M??????,Moncler Jackets?
???????????
?????????????????
?????????????????????
????
??????????????????VIP??????????????????????????????
?1?????????????????VIP????????????
?2??????????????????????????????????VIP???????????????????VIP???????????????????????????
??????????VIP???????????????????????????????????????????????????????????????“???????????????????????????????????????????????????????????????????????????????????????0????????????????????0?????????????????????????????????”???????????????????????????????
?1? ??????????????????值????????????*????????????-???+1?*???????vip????????????????????????????????????值?0?
?2? ?????????(????-????)?????值??0???0???????????????????????????????????????????????????????????
?3? ????????????????????????????????????????????????????????????vip?????????值?0?
?4? ?????=????????+?????格*??????
?5? ????????????????????????
?6? ?????=???????? + ????? + ????? + ?????
?????????“??????????”???????????????
Изображение
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????格??
?1? ????????????????????????????????????????????????????
?2? ???????????????????????????????
?3? ???????????.????????????????????????????????????
common.normal.phone.price --> ??????/???/??/??
common.pack1.phone.price --> ??????/??/??/??
common.pack1.phone.free --> ??????/??/??/????
common.pack1.phone.rent ???????/??/??/???????
vip.normal.phone.price --> ??VIP??/???/??/??
vip.pack1.phone.price --> ??VIP??/??1/??/??
vip.pack2.phone.price --> ??VIP??/??2/??/??
common.new.phone.free --> ??????/???/??/????
vip.new.phone.free --> ??VIP??/???/??/????
?4? ??值?0?????????????????????????????????????????????值?0?
?5? ??vip?????????????????????????????????????????????????????????????
???????????????????????
?1? ?????????????????10k?????????????????????M???K????????????格5?/M??????0.5?/K???????????????????????????????????????????????????????????????????????????10k??????????????????格5?/M???5?/10K???????????????格?????????????????
?2? ??????????????????VIP??????2???????0.5?/M??????????0.5?/10k????????????????????5?/10k????????????????????格???????????????????
????????????????????conf.properties????????
common.normal.phone.price=600common.normal.message.price=100common.normal.data.price=50common.pack1.phone.price=500common.pack1.message.price=100common.pack1.data.price=30common.pack1.phone.rent=20000common.pack1.message.rent=10000common.pack1.data.rent=20000common.pack1.phone.free=60common.pack1.message.free=200common.pack1.data.free=5000vip.normal.phone.price=400vip.normal.message.price=100vip.normal.data.price=30vip.pack1.phone.price=300vip.pack1.message.price=100vip.pack1.data.price=10vip.pack1.phone.free=750vip.pack1.message.free=200vip.pack1.data.free=10000vip.pack2.phone.price=200vip.pack2.message.price=100vip.pack2.data.price=5vip.pack2.phone.free=2000vip.pack2.message.free=500vip.pack2.data.free=30000common.new.phone.free=60common.new.message.free=200common.new.data.free=5000vip.new.phone.free=200vip.new.message.free=200vip.new.data.free=10000
???????????????????????ConfigManager???????????????????????????????????????????????????????????
public class ConfigManager {private static Properties config = new Properties();static{InputStream ips = ConfigManager.class.getResourceAsStream("/conf.properties");try {config.load(ips);} catch (IOException e) {throw new ExceptionInInitializerError(e);}}private static String makePrefix(int customerType,int packType,int businessType){String customerTitle = customerType==0?"common":"vip";String packTitle = packType==0?"normal":("pack"+packType);String businessTitle = businessType==0?"phone":businessType==1?"message":"data";return customerTitle + "." + packTitle + "." + businessTitle;}private static int getNumber(String key){String value = config.getProperty(key);try{return Integer.parseInt(value);}catch(Exception e){return 0;}}public static int getPrice(int customerType,int packType,int businessType){return getNumber(makePrefix(customerType,packType,businessType)+".price");}public static int getFree(int customerType,int packType,int businessType){return getNumber(makePrefix(customerType,packType,businessType)+".free");}public static int getRent(int customerType,int packType,int businessType){return getNumber(makePrefix(customerType,packType,businessType)+".rent");}public static int getNewCustomerFree(int customerType,int businessType){String[] businesses = {"phone","message","data"};return getNumber((customerType==0?"common":"vip")+".new." + businesses[businessType] + ".free");}}
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
???????????????????????????????????????????????????????????????????????????????????????????????????
?1? MobileCorporation??simulationBusiness?????????????????500???????????????????????????????????????????/???/????/???/????/??????
?2? Customer?CommonCustomer?VipCustomer????????VIP????????/???/????/???/????/?????????????VIP????????????????????????????
???????????????????????????????????????????????????????????????????????????????????????????????????Properties??????????值?????????????????????????????????????????????????
?1? ComputeStrategy????computeMoney??
?2? ConfigManager?? ??getPrice?getFree?getRent?getNewCustomerFree????
????????????????????????????????????????VIP????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????“??”?????????“??”?????????值?????????????????????????????????????????????????????????????????????
?1? PackStrategy????orderRent?cancelRent?getValidRent?orderPack?cancelPack?getValidPack???
?2?OrderedStrategyHolder????order?getValidStrategy???
?3?Rent????computeRent??
?????:
Изображение

????????????????????
Изображение
???MobileCorporation?????????
1.?MobileCorporation???????List??????????????????????????????????VIP??????????????????????????????????????????????VIP??????????????????????????????????????????
2.?????????????????List?????15??????5?VIP??????????????????????
3.?MobileCorporation??????simulationBusiness(Date month)????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????500?????????????????????????????????????????20??
4.???????????????????????randDoOneThing(Date month)??????????????????????????????????????????????????????????????????????????
?????
package cn.itcast.mobilecounter.strategy;import java.util.ArrayList;import java.util.Calendar;import java.util.Date;import java.util.Random;public class MobileCorporation {private ArrayList<Customer> customers = new ArrayList<Customer>();public MobileCorporation(){for(int i=1;i<=15;i++){customers.add(new CommonCustomer(i+"?????",new Date(108,10,1)));}for(int i=1;i<=5;i++){customers.add(new VIPCustomer(i+"?VIP??",new Date(108,10,1)));}System.out.println("???????????5?VIP???15?????????????????2008?10?1?.");}//??????????public void simulationBusiness(Date month){for(Customer customer : customers){customer.monthBegin();}System.out.println("--------being simulating " + DateUtil.formatDateToMonth(month) + "--------------");for(int i=0;i<500/*30*/;i++){randDoOneThing(month);}System.out.println(DateUtil.formatDateToMonth(month)+"????????");//????????for(int i=0;i<customers.size();i++){customers.get(i).countMonthMoney(month);}}/** * ???????????? * */private void randDoOneThing(Date month){Calendar calendar = Calendar.getInstance();calendar.setTime(month);calendar.add(Calendar.MONTH, 1);Date monthOfOrderPack = calendar.getTime();/*?orderPack?cancelPack?joinNewCustomer???????????1/20?*/int rand = new Random().nextInt(63);if(rand>=0 && rand<20){callPhone();}else if(rand>=20 && rand<40){sendMessage();}else if(rand>=40 && rand<60){transferData();}else{switch(rand){case 60:orderPack(monthOfOrderPack);break;case 61:cancelPack(monthOfOrderPack);break;case 62:joinNewCustomer(month);break;}}}/** * ?????????????????????1?10???? */private void callPhone(){int rand = new Random().nextInt(customers.size());Customer customer = customers.get(rand);int phoneTimes = new Random().nextInt(10) + 1;customer.callPhone(phoneTimes);System.out.println(customer + "??" + phoneTimes + "????");}/** * ?????????????????????1?10??? */private void sendMessage(){int rand = new Random().nextInt(customers.size());Customer customer = customers.get(rand);int messageNumbers = new Random().nextInt(10) + 1;customer.sendMessage(messageNumbers);System.out.println(customer + "??" + messageNumbers + "???");}/** * ?????????????????????50K?100K?200K?500K?1M */private void transferData(){int rand = new Random().nextInt(customers.size());Customer customer = customers.get(rand);int [] dataSize = new int[]{50,100,200,500,1000};int randSizeKey = new Random().nextInt(5);customer.transferData(dataSize[randSizeKey]);System.out.println(customer + "???" + dataSize[randSizeKey] + "k??");}/** * ??????????????????? */private void orderPack(Date month){int rand = new Random().nextInt(customers.size());customers.get(rand).randomOrderPack(month);}/** * ???????????????????? */private void cancelPack(Date month){int rand = new Random().nextInt(customers.size());customers.get(rand).randomCancelPack(month);}private void joinNewCustomer(Date month){Calendar calendar = Calendar.getInstance();calendar.setTime(month);int maxDay = calendar.getMaximum(Calendar.DAY_OF_MONTH);int randDay = new Random().nextInt(maxDay) + 1;/*?????????????????date???????Calendar???? * ??????????clone????? */ Date joinTime = (Date)month.clone();joinTime.setDate(randDay);int randType = (new Random().nextInt(10))%2;Customer customer = null;if(randType == 0){int commonId = IdGenerator.getInstance().nextCommonId();customer = new CommonCustomer(commonId+"?????",joinTime);customers.add(customer);}else{int vipId = IdGenerator.getInstance().nextVipId();customer = new VIPCustomer(vipId+"?VIP??",joinTime);customers.add(customer);}System.out.println(DateUtil.formatDateToDay(joinTime) + "????" + customer);}}
???IdGenerator????????Id???
1.???????????15??????5?VIP???????????????????16???????VIP????????6???
2.??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
?????
public class IdGenerator {private IdGenerator(){}private static IdGenerator instance = new IdGenerator();public static IdGenerator getInstance(){return instance;}private int lastCommonId = 15;private int lastVipId = 5;public synchronized int nextCommonId(){return ++lastCommonId;}public synchronized int nextVipId(){return ++lastVipId;}}
???MainClass????????????
1.??MobileCorporation??simulationBusiness(Date date)???????15???????
?????
public class MainClass {public static void main(String[] args) {MobileCorporation corp = new MobileCorporation();//??????????Date month = new Date(109,0,1);System.out.println("???????2009?1?1??????15???????.");//????15??????for(int i=0;i<15/*3*/;i++){corp.simulationBusiness(month);Calendar calendar = Calendar.getInstance();calendar.setTime(month);calendar.add(Calendar.MONTH, 1);month = calendar.getTime();}}}
???Customer???????VIP????????
1.?Customer???????????????????4?List?????????????????????????????????????????????????????????? Customer????????????????????????????????????????????????
2.?Customer??????????????????????????????List???????????????????????????????????VIP?????????????????????????????Customer???????????????????????????VIP?????????????????
3.?Customer???????countMonthMoney????????????????????????????????????????????????????????????????????????????????????????????????????????
?????
public abstract class Customer {protected String name;//???????private Date joinTime;private int customerType = 0;protected List<ActionRecord> actionRecords = new ArrayList<ActionRecord>();//???????????????????????????private ArrayList phoneRecords = new ArrayList();//???????????????????????????private ArrayList messageRecords = new ArrayList();//?????????????????????????????private ArrayList dataRecords = new ArrayList();protected PackStrategy packStrategy;public void monthBegin(){phoneRecords.clear();messageRecords.clear();dataRecords.clear();actionRecords.clear();}public Customer(String name,Date joinTime,int customerType){this.name = name;this.joinTime = joinTime;this.customerType = customerType;}public String toString(){return name;}public void callPhone(int times){phoneRecords.add(times);actionRecords.add(new ActionRecord("???",times + "??"));}public void sendMessage(int numbers){messageRecords.add(numbers);actionRecords.add(new ActionRecord("???",numbers + "?"));}public void transferData(int size){dataRecords.add(size);actionRecords.add(new ActionRecord("???",size + "k"));}/** * * @param currentMonth ?????????????? * ?????????1???????????????? */public int countMonthMoney(Date currentMonth){boolean newcome = !joinTime.before(currentMonth);//joinTime.after(currentMonth);int totalPhone = gatherRecords(phoneRecords);int totalMessage = gatherRecords(messageRecords);int totalData = gatherRecords(dataRecords);int freePhone = 0;int freeMessage = 0;int freeData = 0;if(newcome){freePhone = ConfigManager.getNewCustomerFree(customerType,0);freeMessage = ConfigManager.getNewCustomerFree(customerType,1);freeData = ConfigManager.getNewCustomerFree(customerType,2);}int chargePhone = totalPhone>freePhone?totalPhone-freePhone:0;int chargeMessage = totalMessage>freeMessage?totalMessage-freeMessage:0;int chargeData = totalData>freeData?totalData-freeData:0;//????:?????????????????????????????System.out.println(name + "," + DateUtil.formatDateToDay(joinTime) + "??.");System.out.println(" ??????-----");for(int i=0;i<actionRecords.size();i++){System.out.println(" " + actionRecords.get(i));}System.out.println(" ??????-----");System.out.println(" ??:" + phoneRecords + "??:??" + messageRecords + "?:??" + dataRecords + "k");System.out.println(" ????:" + totalPhone + "????????" + freePhone + "???????" + chargePhone + "??");System.out.println(" ????:" + totalMessage + "???????" + freeMessage + "??????" + chargeMessage + "?");System.out.println(" ????:" + totalData + "k??????" + freeData + "k?????" + chargeData + "k");ComputeStrategy phoneStrategy = packStrategy.getValidPhonePack(currentMonth);ComputeStrategy messageStrategy = packStrategy.getValidMessagePack(currentMonth);ComputeStrategy dataStrategy = packStrategy.getValidDataPack(currentMonth);int sum = 0;//VIP???????????Rent rent = packStrategy.getValidRent(currentMonth);if(rent != null){int rentMoney = rent.coputeRent(joinTime,currentMonth);sum += rentMoney;System.out.println(" ????????" + rentMoney + "??");}sum += phoneStrategy.computeMoney(chargePhone);sum += messageStrategy.computeMoney(chargeMessage);sum += dataStrategy.computeMoney(chargeData/10);System.out.println(" ???" + sum/1000f + "??");return sum;}private int gatherRecords(ArrayList records){int sum = 0;for(int i=0;i<records.size();i++){sum += (Integer)(records.get(i));}return sum;}public abstract void randomCancelPack(Date month);public abstract void randomOrderPack(Date month);}
???ActionRecord????????????
1.??????????????????????
?????
public class ActionRecord {private String name;private String value;public ActionRecord(String name, String value) {this.name = name;this.value = value;}public String toString(){return name + ":" + value;}}
???CommonCustomer?????????
1.????????????????值???????0???????????0????????????null?
2.????????????????????????????????????????????????????????????????1?????????????????????????0???????????????????????????????????????????????????????
?????
public class CommonCustomer extends Customer {public CommonCustomer(String name,Date joinTime){super(name,joinTime,0);packStrategy = new PackStrategy(0,0,null);actionRecords.add(new ActionRecord(name, DateUtil.formatDateToDay(joinTime)+"??"));}public void randomCancelPack(Date orderedMonth){int rand = new Random().nextInt(3);switch(rand){case 0:/*if(packStrategy.getOrderedPhonePack() == null packStrategy.getOrderedPhonePack().getPackType() == 0){System.out.println(name + "????????????????");return;}*/packStrategy.cancelPhonePack(orderedMonth);System.out.println(name + "???" + "????" + "??" + DateUtil.formatDateToMonth(orderedMonth) + "???");actionRecords.add(new ActionRecord("??????",""));break;case 1:/*if(packStrategy.getOrderedMessagePack() ==null packStrategy.getOrderedMessagePack().getPackType() == 0){System.out.println(name + "????????????????");return;}*/packStrategy.cancelMessagePack(orderedMonth);System.out.println(name + "???" + "????" + "??" + DateUtil.formatDateToMonth(orderedMonth) + "???");actionRecords.add(new ActionRecord("??????",""));break;case 2:/*if(packStrategy.getOrderedDataPack()==null packStrategy.getOrderedDataPack().getPackType() == 0){System.out.println(name + "????????????????");return;}*/packStrategy.cancelDataPack(orderedMonth);System.out.println(name + "???" + "????" + "??" + DateUtil.formatDateToMonth(orderedMonth) + "???");actionRecords.add(new ActionRecord("??????",""));break;}}public void randomOrderPack(Date month){int rand = new Random().nextInt(3);switch(rand){case 0://if(packStrategy.getOrderedPhonePack()==null packStrategy.getOrderedPhonePack().getPackType() == 0){packStrategy.orderPhonePack(month,1);System.out.println(name + "???" + "????" + "??" + DateUtil.formatDateToMonth(month) + "??)");actionRecords.add(new ActionRecord("?????",""));//}break;case 1://if(packStrategy.getOrderedMessagePack() == null packStrategy.getOrderedMessagePack().getPackType() == 0){packStrategy.orderMessagePack(month,1);System.out.println(name + "???" + "????" + "??" + DateUtil.formatDateToMonth(month) + "??)");actionRecords.add(new ActionRecord("?????",""));//}break;case 2://if(packStrategy.getOrderedDataPack() == null packStrategy.getOrderedDataPack().getPackType() == 0){packStrategy.orderDataPack(month,1);System.out.println(name + "???" + "????" + "??" + DateUtil.formatDateToMonth(month) + "??)");actionRecords.add(new ActionRecord("?????",""));//}break;}}}
???VIPCustomer?????????
1.????????????????值???????1???????????0????????????????????
2.?????????????????????????????????1???2?????1???2???????????????????????1?2???????Rent??????????????????????????????0???????Rent???????????????????????????????????????????????????????????????
?????
public class VIPCustomer extends Customer {public VIPCustomer(String name,Date joinTime){super(name,joinTime,1);packStrategy = new PackStrategy(1,0,new Rent(200,RentUnit.DAY));actionRecords.add(new ActionRecord(name, DateUtil.formatDateToDay(joinTime)+"??"));}public void orderPack1(Date month){/*if(packStrategy.getOrderedPhonePack()==null packStrategy.getOrderedPhonePack().getPackType() != 1){*/packStrategy.orderRent(month,new Rent(10000,RentUnit.MONTH));packStrategy.orderPhonePack(month,1);packStrategy.orderMessagePack(month,1);packStrategy.orderDataPack(month,1);System.out.println(name+ "?????1" + "??" + DateUtil.formatDateToMonth(month) + "???" );actionRecords.add(new ActionRecord("????1",""));//}}public void orderPack2(Date month){/*if(packStrategy.getOrderedPhonePack() ==null packStrategy.getOrderedPhonePack().getPackType() != 2){*/packStrategy.orderRent(month,new Rent(20000,RentUnit.MONTH));packStrategy.orderPhonePack(month,2);packStrategy.orderMessagePack(month,2);packStrategy.orderDataPack(month,2);System.out.println(name+ "?????2" + "??" + DateUtil.formatDateToMonth(month) + "???" );actionRecords.add(new ActionRecord("????2",""));//}}public void randomCancelPack(Date orderedMonth){/*if(packStrategy.getOrderedPhonePack() ==null packStrategy.getOrderedPhonePack().getPackType() == 0){System.out.println(name + "??????????????"); return; } */packStrategy.orderRent(orderedMonth, new Rent(200, RentUnit.DAY));packStrategy.orderPhonePack(orderedMonth, 0);packStrategy.orderMessagePack(orderedMonth, 0);packStrategy.orderDataPack(orderedMonth, 0);System.out.println(name + "???" + "??" + "??"+ DateUtil.formatDateToMonth(orderedMonth) + "???");actionRecords.add(new ActionRecord("????", ""));}public void randomOrderPack(Date month){//????????????????????????int randType = (new Random().nextInt(10))%2;if(randType == 0){orderPack1(month);}else if(randType == 1){orderPack2(month);}}}
???DateUtil?????格???????????
?????
public class DateUtil {public static String formatDateToMonth(Date date){SimpleDateFormat sdf = new SimpleDateFormat("yyyy?MM?");String result = sdf.format(date);return result;}public static String formatDateToDay(Date date){SimpleDateFormat sdf = new SimpleDateFormat("yyyy?MM?dd?");String result = sdf.format(date);return result;}}
???ComputeStrategy???????????????
1.??????????????????????????????????????????????????????????????值???????????????????????????????????????????????????????????????????????????????????值???
2.??VIP???common?????????????????????????????????????????????????????????????????????????PhoneComputeStrategy?MessageComputeStrategy?DataComputeStrategy?????ComputeStragtegy?????????????????????????????值????????????????????
?????
public class ComputeStrategy {private int customerType;private int packType;private int businessType;private String businessName = "";public ComputeStrategy(int customerType, int packType, int businessType) {this.customerType = customerType;this.packType = packType;this.businessType = businessType;switch(businessType){case 0:businessName = "??";break;case 1:businessName = "??";break;case 2:businessName = "??";break;}}public int computeMoney(int quantity){int price = ConfigManager.getPrice(customerType, packType,businessType);int freeQuantity = ConfigManager.getFree(customerType, packType,businessType);int chargeQuantity = quantity - freeQuantity;if(chargeQuantity < 0){chargeQuantity = 0;}int phoneBaseMoney = ConfigManager.getRent(customerType, packType,businessType);System.out.print(businessName + "????" + phoneBaseMoney + "??,");int fee = price * chargeQuantity;System.out.println(businessName + "????" + quantity + "-" + freeQuantity + "=" + chargeQuantity + "," + chargeQuantity + "*" + price + "=" + fee +"??");return phoneBaseMoney + fee;}}
???Rent??????VIP???????????
1.VIP????????????????????????????????????????????????????????????????????????Rent??????????????????????????????????????????Rent?????????????????????????
?????
public class Rent {private int price;private RentUnit unit = RentUnit.MONTH;public Rent(int price,RentUnit unit){this.price = price;this.unit = unit;}public int coputeRent(Date startTime,Date currentMonth){//????????????????if(unit == RentUnit.DAY){Calendar start = Calendar.getInstance();start.setTime(startTime);Calendar end = Calendar.getInstance();end.setTime(currentMonth);//?????????????end.set(Calendar.DAY_OF_MONTH, 1);end.add(Calendar.MONTH, 1);end.add(Calendar.DAY_OF_MONTH, -1);int days = end.get(Calendar.DAY_OF_MONTH) ;if(end.get(Calendar.MONTH) == start.get(Calendar.MONTH)){days -= start.get(Calendar.DAY_OF_MONTH) + 1;}return price*days;}else{return price;}}}
Rent?????????RentUnit?????????????MONTH?DAY????? ??????
public enum RentUnit {DAY,MONTH;}
????PackStrategy??????????????????
??????????????????????????????????????????
1.?????2?????3????????????2??????????????????????????????????????3???????????????????????????????????????????PackStrategy??????????ComputeStrategy????????????????????????????????????????
2.
?? ??2??????3??????? 2????2????????????3????3????????????
?? 2????2???????PackStrategy??????????????? 3????3?????????????????
??????????????????PackStrategy?????????????????????????????????????????????????????????“????????????”?????“??????????????????????”?????????????????????????,Nike Air Max Men????PackStrategy???????????????
3.
?? 2???????????0? 2??????3??????1?3???????4??????2????3????3????????????
?? 3????3???????????1?????????3??4????2??????????????值????? 2?????3???????1????PackStrategy???????????????0????3????3???????????????????????2?????3???????1?值?PackStrategy????????????????????????3??4????2??????值,Beats By Dre Sale????3????3?????????PackStrategy???????????????????2?????3???????1?
4.
?? 2???????????0? 2???????3??????1???????2??????????3????????????2????2????2????????????
??????2??????????0???????2??????????3??????2??????????????值????? 2?????3???????1???????2?????3???????1?值?PackStrategy????????????????????????????????????
?????????????????????????????????????? “??????????”?????????????“??????????”??“??????????”???????????????????1??????????????值?PackStrategy????????????????????????????????????????????????????????????????????????????????值?PackStrategy?????????????????????? ???????????????,Vibram Fiver Finger Shoes?
5.?????????????????????????????????????????????????????????值?PackStrategy?????????????????????? ???????PackStrategy?????????????????????????????????????????????????????????????????????????????????????????????????????
?????
public class PackStrategy {private int customerType;private int packType = 0;private ComputeStrategy currentStrategies[] = new ComputeStrategy[3];private Rent rent; private OrderedStrategyHolder<ComputeStrategy> orderedStrategies[] = new OrderedStrategyHolder[]{ new OrderedStrategyHolder<ComputeStrategy>(), new OrderedStrategyHolder<ComputeStrategy>(), new OrderedStrategyHolder<ComputeStrategy>(),};private OrderedStrategyHolder<Rent> orderedRent = new OrderedStrategyHolder<Rent>();public PackStrategy(int customerType,int packType,Rent rent){this.customerType = customerType;this.packType = packType;this.rent = rent;for(int i=0;i<3;i++){currentStrategies[i] = new ComputeStrategy(customerType, packType,i);}}public Rent getValidRent(Date month){Rent validRent = orderedRent.getValidComputeStrategy(month); return validRent==null?rent:validRent;}public void orderRent(Date orderedMonth,Rent rent){Rent oldRent = orderedRent.order(orderedMonth, rent);if(oldRent != null){this.rent = oldRent;}}public void cancelRent(Date orderedMonth,Rent rent){orderRent(orderedMonth,null);}public ComputeStrategy getValidPhonePack(Date month){ComputeStrategy computeStrategy = (ComputeStrategy)orderedStrategies[0].getValidComputeStrategy(month); return computeStrategy==null?currentStrategies[0]:computeStrategy;}public ComputeStrategy getValidMessagePack(Date month){ComputeStrategy computeStrategy = (ComputeStrategy)orderedStrategies[1].getValidComputeStrategy(month); return computeStrategy==null?currentStrategies[1]:computeStrategy;}public ComputeStrategy getValidDataPack(Date month){ComputeStrategy computeStrategy = (ComputeStrategy)orderedStrategies[2].getValidComputeStrategy(month); return computeStrategy==null?currentStrategies[2]:computeStrategy;}public void orderPhonePack(Date orderedMonth,int packType){ComputeStrategy oldComputeStrategy = orderedStrategies[0].order(orderedMonth, new ComputeStrategy(customerType, packType, 0));if(oldComputeStrategy != null){this.currentStrategies[0] = oldComputeStrategy;}}public void orderMessagePack(Date orderedMonth, int packType){ComputeStrategy oldComputeStrategy = orderedStrategies[1].order(orderedMonth, new ComputeStrategy(customerType, packType, 1));if(oldComputeStrategy != null){this.currentStrategies[1] = oldComputeStrategy;}}public void orderDataPack(Date orderedMonth, int packType){ComputeStrategy oldComputeStrategy = orderedStrategies[2].order(orderedMonth, new ComputeStrategy(customerType, packType, 2));if(oldComputeStrategy != null){this.currentStrategies[2] = oldComputeStrategy;}}public void cancelPhonePack(Date orderedMonth){orderPhonePack(orderedMonth, 0);}public void cancelMessagePack(Date orderedMonth){orderMessagePack(orderedMonth, 0);}public void cancelDataPack(Date orderedMonth){orderDataPack(orderedMonth, 0);}/*public PhoneComputeStrategy getOrderedPhonePack(){PhoneComputeStrategy phoneHolderStrategy = (PhoneComputeStrategy)phoneOrderedStrategyHolder.getOrderedStrategy(); return phoneHolderStrategy;}public MessageComputeStrategy getOrderedMessagePack(){MessageComputeStrategy messageHolderStrategy = (MessageComputeStrategy)messageOrderedStrategyHolder.getOrderedStrategy(); return messageHolderStrategy;}public DataComputeStrategy getOrderedDataPack(){DataComputeStrategy dataHolderStrategy = (DataComputeStrategy)dataOrderedStrategyHolder.getOrderedStrategy(); return dataHolderStrategy;}*/}
????OrderedStrategyHolder?????????????????
1.???????????????????????????????????????????????????????????????????????????????????????????????VIP??????????????????????????????????????????????????????????????????????????????????????ComputeStrategy????????Rent??????????????????????????????????????????????????????????
2.????????????order()?????????????????????PackStrategy??????????????????????????????????????????????????????????????????????????????????????????????????值?PackStrategy?????????????????????? ???????PackStrategy??????????????????????????????????????????????????order???????order?????????????????????????????????????????????????????????????????????????????????????null????????????????????????PackStrategy??????????????????????????????????? PackStrategy????order?????????????????????
3. ????????????????????????????????????????????????????????????????????????????????getValidStrategy()???????????????????????????????????????null?
?????
public class OrderedStrategyHolder<T> {private Date orderedMonth;private T computeStrategy;public T order(Date orderedMonth,T computeStrategy){T oldComputeStrategy = null;if(this.orderedMonth!=null && this.orderedMonth.before(orderedMonth)){oldComputeStrategy = this.computeStrategy;}this.orderedMonth = orderedMonth;this.computeStrategy = computeStrategy;return oldComputeStrategy;}public T getValidComputeStrategy(Date month){if(this.orderedMonth!=null && !month.before(orderedMonth)){return computeStrategy;}return null;}}
Related articles?


http://bbs.phfund.com.cn/forumdisplay.php?fid=6

Вернуться к началу