aboutsummaryrefslogtreecommitdiff
path: root/robottino/all_versions/v4.1/src/List.java
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xrobottino/all_versions/v4.1/src/List.java74
1 files changed, 74 insertions, 0 deletions
diff --git a/robottino/all_versions/v4.1/src/List.java b/robottino/all_versions/v4.1/src/List.java
new file mode 100755
index 0000000..13a8ab6
--- /dev/null
+++ b/robottino/all_versions/v4.1/src/List.java
@@ -0,0 +1,74 @@
1/*
2Copyright 2008, 2009 Sebastiano Tronto <sebastiano@luganega.org>
3
4This file is part of Robottino.
5
6 Robottino is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 Robottino is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with Robottino; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
20*/
21
22import javax.swing.JOptionPane;
23
24public class List {
25 public static Main main = new Main();
26 public Robot primoRobot, ultimoRobot;
27 public List() {
28 primoRobot = ultimoRobot = null;
29 }
30 public boolean vuota() {
31 return primoRobot == null;
32 }
33 public Robot getRobot( String nome ) {
34 Robot i = primoRobot;
35 for ( ; !i.nomeRobot.equals( nome ); i = i.prossimoRobot ) ;
36 return i;
37 }
38 public void newRobot() {
39 newRobot( false, false, false, false, "" );
40 }
41 public void newRobot( String nome ) {
42 newRobot( false, false, false, false, nome );
43 }
44 public void newRobot( boolean la, boolean ra, boolean ll, boolean rl, String nome ) {
45 if ( vuota() )
46 primoRobot = ultimoRobot = new Robot( la, ra, ll, rl, nome, null, null );
47 else {
48 ultimoRobot = new Robot( la, ra, ll, rl, nome, ultimoRobot, null );
49 ultimoRobot.precedenteRobot.prossimoRobot = ultimoRobot;
50 }
51 }
52 public void deleteRobot( String nome ) {
53 if ( vuota() )
54 JOptionPane.showMessageDialog( main.frame, "Nessun robottino presente. Impossibile cancellarne uno", "Robottino v4.1 - Errore", JOptionPane.ERROR_MESSAGE );
55 else {
56 Robot i = primoRobot;
57 for ( ; !i.nomeRobot.equals( nome ); i = i.prossimoRobot ) ;
58 if ( i.precedenteRobot != null )
59 i.precedenteRobot.prossimoRobot = i.prossimoRobot;
60 else
61 primoRobot = i.prossimoRobot;
62 if ( i.prossimoRobot != null )
63 i.prossimoRobot.precedenteRobot = i.precedenteRobot;
64 else
65 ultimoRobot = i.precedenteRobot;
66 }
67 }
68 public void printList() {
69 String lista = "";
70 for ( Robot i = primoRobot; i != null; i = i.prossimoRobot )
71 lista += i.getName() + " ";
72 JOptionPane.showMessageDialog( main.frame, lista, "Robottino v4.1 - Robottini Presenti", JOptionPane.PLAIN_MESSAGE );
73 }
74} \ No newline at end of file

Generated with cgit - Back to sebastiano.tronto.net