Biblioteca Java - Blame information for rev 3
Subversion Repositories:
Rev | Author | Line No. | Line |
---|---|---|---|
3 | mihai | 1 | /* |
2 | * To change this license header, choose License Headers in Project Properties. | ||
3 | * To change this template file, choose Tools | Templates | ||
4 | * and open the template in the editor. | ||
5 | */ | ||
6 | package designpatterns.mvc.gara; | ||
7 | |||
8 | /** | ||
9 | * | ||
10 | * @author evo2 | ||
11 | */ | ||
12 | public class GaraControler { | ||
13 | private Gara gara; | ||
14 | private GaraView garaView; | ||
15 | |||
16 | GaraControler(Gara gara){ | ||
17 | this.gara = gara; | ||
18 | this.garaView = new GaraView(this); | ||
19 | //inregistreaza garaView ca si obsever pentru gara. de fiecare data cand starea garii se shcimba view-ul va fi notificat | ||
20 | this.gara.addObserver(garaView); | ||
21 | garaView.setVisible(true); | ||
22 | } | ||
23 | |||
24 | public void schimbaSemafor(){ | ||
25 | gara.setSemafor(!gara.getSemafor()); | ||
26 | } | ||
27 | |||
28 | public boolean adaugaTren(String tren){ | ||
29 | if(gara.getSemafor() == true){ | ||
30 | gara.setTrenLinia1(tren); | ||
31 | return true; | ||
32 | } | ||
33 | else | ||
34 | return false; | ||
35 | } | ||
36 | |||
37 | } |