<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) 評(píng)論(0)  編輯  收藏 所屬分類(lèi): 工作學(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.

    主站蜘蛛池模板: 四虎影视在线影院在线观看免费视频| 一级毛片完整版免费播放一区| 99爱视频99爱在线观看免费| 亚洲va久久久噜噜噜久久狠狠| 全免费一级毛片在线播放| 亚洲一区精彩视频| 成人永久免费高清| 免费无码午夜福利片69| 亚洲中文字幕丝袜制服一区| 免费看黄网站在线看| 亚洲日本中文字幕天堂网| 一级一级一级毛片免费毛片| 久久亚洲欧洲国产综合| a国产成人免费视频| 成人免费视频国产| 色视频在线观看免费| 国产av无码专区亚洲av果冻传媒| 国产精品综合专区中文字幕免费播放| 国产亚洲精品激情都市| 午夜免费啪视频在线观看| 亚洲va在线va天堂成人| 伊人久久亚洲综合影院| 亚洲区精品久久一区二区三区| 日韩精品无码区免费专区| 色屁屁在线观看视频免费| 亚洲Av无码精品色午夜 | 最近的2019免费中文字幕| 久久亚洲精品AB无码播放| 色婷婷7777免费视频在线观看| 亚洲jizzjizz少妇| 亚洲日韩一页精品发布| 人禽杂交18禁网站免费| 中美日韩在线网免费毛片视频| 亚洲AV无码AV男人的天堂| 性色av免费观看| 99久久99这里只有免费的精品| 亚洲天堂福利视频| 亚洲人成色77777在线观看大| 国产亚洲精品bv在线观看| 永久看日本大片免费35分钟| 无码亚洲成a人在线观看|