E D R , A S I H C RSS

Connecting The Dots



μ†ŒμŠ€μ½”λ“œλ₯Ό 보면 λ‹€μŒμ˜ ν΄λž˜μŠ€λ“€ 관계가 MVP 이닀.
Game - Model. κ΄€κ³„λŠ” Presenter μ™€λ§Œ λ§ΊλŠ”λ‹€. μ™ΈλΆ€μ—μ„œ μ΄λ²€νŠΈκ°€ λ°œμƒν–ˆμ„λ•ŒλŠ” Presenter λ₯Ό 톡해 ν†΅μ§€λ°›λŠ”λ‹€.

BoardPanel - View. μ‹€μ œ Swing λ“± ꡬ체적 λΌμ΄λΈŒλŸ¬λ¦¬λ“€μ„ 이용, μ‹€μ œ ν‘œν˜„μ„ ν•œλ‹€. BoardPresenter 와 μƒν˜Έμ°Έμ‘° 관계λ₯Ό κ°€μ§„λ‹€.

BoardPresenter - Presenter. Game κ³Ό BoardPanel μ‚¬μ΄μ˜ μΌμ’…μ˜ Mediator. Game 은



관계λ₯Ό λ§ΊλŠ” μ½”λ“œλŠ” Dots.java 에 μžˆλ‹€. 즉, initialize() λ₯Ό 보면 λ‹€μŒμ˜ μ½”λ“œκ°€ λ‚˜μ˜¨λ‹€.
~cpp 
      _game = new Game(4, Arrays.asList(new String[] {"JL", "TL", "KML"}));

      BoardPanel boardPanel = new BoardPanel();
      boardPanel.setGame(_game);
μ‹€μ œλ‘œ BoardPanel.setGame 을 보면
~cpp 
   public void setGame(Game game) {
      _presenter = new BoardPresenter(game, this);
      _pixelSize = getIdealSize();
      setSize(_pixelSize);
   }
이며 BoardPresenter λ₯Ό 보면
~cpp 
   public BoardPresenter(Game game, BoardPresenterDrawListener listener) {
      _game = game;
      _game.addListener(this);
      _listener = listener;
   }
이닀. (BoardPresenter μ—μ„œ listener λŠ” BoardPanel)

그리고 BoardPanel μ—μ„œ 이벀트 λ°œμƒμ‹œμ—λŠ”
BoardPanel.mouseReleased -> BoardPresenter.processClick -> Game.join μ‹μœΌλ‘œ 호좜되며
Game 객체의 데이터가 λ°”λ€ŒλŠ” κ²½μš°μ—λŠ” (ex : boxClosed)
Game.boxClosed -> listener.boxClosed (μ—¬κΈ°μ„œ listener λŠ” Presenter. Presenter 듀은 μ—¬λŸ¬κ°œκ°€ 될 수 μžˆλ‹€. Game 객체에 addListener 둜 λ“±λ‘λœ 만큼) -> BoardPanel.drawInitials. μ‹μœΌλ‘œ 도메인 λͺ¨λΈλ‘œλΆ€ν„° μ˜¬λΌμ˜¨λ‹€.

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:23:00
Processing time 0.0102 sec