<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    rednight

    0x2B|~0x2B,That's not a question,Just do it.
    posts - 32, comments - 14, trackbacks - 0, articles - 0

    state pattern

    Posted on 2006-12-26 14:46 rednight 閱讀(343) 評論(0)  編輯  收藏 所屬分類: 工作學(xué)習(xí)
    The logic to change state is only inside one method (initVesselView(…)) inside GrVessel.java.?

    if (viewType == VIEW_STOWAGE) {
    ??????????? vslView_ = new VesselStowageView(leftPoint, bow2Left, leftCenter,
    ???????????????????????????????????????????? rightCenter, shipWidth_);
    ??????? }
    ??????? else if (viewType == VIEW_SIDE) {
    ??????????? vslView_ = new VesselSideView(leftPoint, bow2Left, leftCenter,
    ????????????????????????????????????????? rightCenter, shipWidth_);
    ??????? }
    ??????? else if (viewType == VIEW_PLAN) {
    ??????????? vslView_ = new VesselPlanView(leftPoint, bow2Left, leftCenter,
    ????????????????????????????????????????? rightCenter, shipWidth_);
    ??????? }
    ??????? else {
    ??????????? throw new IllegalArgumentException(
    ??????????????? "GrVessel::initVesselView-->Invalid view type!");
    ??????? }


    We do not need to repeat this logic of changing view in many other method.
    This is the benefit of State design pattern.
    The 3 state classes here are VesselPlanView.java, VesselSideView.java and VesselStowageView.java

    Please note that in the state classes, if a method is supported by stateA and not supported by stateB.?
    Then, in stateB, the method body will throw an exception (IllegalArgumentException) to indicate that coder call the wrong method in the wrong state.

    Example, in VesselPlanView.java, public boolean addStowage(...).? This method is only meaningful to stowageView.

    public boolean addStowage(IlvManager manager, List transformList, IlvGraphic stowage, String stadBayN,
    ????????????????????????????? boolean isSelect) {
    ??????? throw new IllegalArgumentException(
    ??????????????? "GrVessel::addStowage-->be sure the vessel at stowage view!");
    ??? }


    Hence, in PlanView, the method body will throw exception.

    Just to share with you a better way to code.

    主站蜘蛛池模板: 亚洲av日韩av永久在线观看| 激情五月亚洲色图| 免费人成动漫在线播放r18| 91在线视频免费91| 亚洲国产精品综合福利专区| 日韩插啊免费视频在线观看 | 女性自慰aⅴ片高清免费| 亚洲欧洲日产国码在线观看| 免费成人激情视频| 人妻丰满熟妇无码区免费 | 亚洲视频在线观看网址| 99久久人妻精品免费二区| 91精品国产亚洲爽啪在线影院| 久久aa毛片免费播放嗯啊| 亚洲精品电影天堂网| 免费国产作爱视频网站| 亚洲小说图区综合在线| 国产成人无码区免费A∨视频网站 国产成人涩涩涩视频在线观看免费 | 十八禁视频在线观看免费无码无遮挡骂过 | 亚洲A∨无码一区二区三区| 亚洲熟妇无码AV不卡在线播放| 大地资源二在线观看免费高清 | 久久青草国产免费观看| 亚洲理论片在线观看| 四虎影院免费视频| 精品国产呦系列在线观看免费 | 亚洲国产午夜精品理论片在线播放| 日本久久久免费高清| 亚洲人精品午夜射精日韩| 久久久久久影院久久久久免费精品国产小说 | 国产精品免费大片一区二区| 亚洲AV无码乱码国产麻豆| 24小时日本韩国高清免费| 亚洲欧美第一成人网站7777| 久久精品国产免费一区| 免费又黄又硬又爽大片| 在线免费播放一级毛片| 亚洲一级毛片免费观看| 国产zzjjzzjj视频全免费| 国产亚洲免费的视频看| 成人亚洲国产va天堂|