TestAscensore.java - ITSOS Marie Curie

annuncio pubblicitario
TestAscensore.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
05/Apr/2011
/**
* This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/** @(#)TestAscensore.java
* Classe che simula l'uso di un ascensore
*
* @author Giovanna Correddu
* @version 1.00 2011/4/5
*/
import javax.swing.*;
public class TestAscensore {
/**
* Creates a new instance of <code>TestAscensore</code>.
*/
public TestAscensore() {
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Object[] options = {"SALI", "SCENDI","APRI PORTE", " CHIUDI PORTE", "ESCI" };
possibili
Ascensore a=new Ascensore(5); // crea un'istanza di ascensore
int scelta;
// ripete finchè non viene scelto "ESCI"
do {
scelta= JOptionPane.showOptionDialog(null,
"Cosa vuoi fare? ",
"Usa ascensore",
JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE,
null,
options,
options[4]);
switch (scelta){
case 0: a.sali();
break;
case 1: a.scendi();
break;
case 2: a.apri();
break;
case 3: a.chiudi();
break;
case 4: break;
}
a.visualizzaStato(); // visualizza stato alla consolle
}
while (scelta!=4);
}
}
1 of 1
//array delle opzioni
Scarica