State, strategy pattern

Purpose and task

Objective: familiar with the UML, familiar with the state policy mode.

Task: Following the experimental content requirements, the completion of use, strategies to achieve experimental mode content.

Content preview

UML review the contents of the course, familiar with the state, the strategy pattern.

Experiment contents and requirements

  • Status Mode:

1, using the state model, to achieve the cancellation of the landing operation, and FIG class given implementation.

  • Strategy Mode:
    1. Various existing sorting algorithms, such as bubble sort, quick sort, dibasic sorting, to design a sorting system, according to the ranking algorithm can dynamically above, incorporate the policy model to achieve the tool and the class is given in FIG.

 

The results (available Continued)

A: Status Mode

Context (Environment category):

State (Status abstract class):

ConcreteState (specific state category):

LoginState.java:

LogoutState.java:

Main.java:

operation result:

Class Diagram:

II: Strategy Mode

Context (Environment category):

At Strategy (Strategy abstract class):

ConcreteStrategy (specific policy class):

Main.java:

operation result:

Class Diagram:

 

Questions:

  1. Please use the state diagram describing the status of the elevator doors?

 

2, a variety of cinema ticket fare discount, fare system design calculations, is given class diagram.

 

 

Guess you like

Origin blog.csdn.net/yszbrzdd/article/details/93522462