Nr. Incontro | I | II | III | IV | V | VI | VII |
1 | 1 - 8 | 2 - 8 | 3 - 8 | 4 - 8 | 5 - 8 | 6 - 8 | 7 - 8 |
2 | 2 - 7 | 3 - 1 | 4 - 2 | 5 - 3 | 6 - 4 | 7 - 5 | 1 - 6 |
3 | 3 - 6 | 4 - 7 | 5 - 1 | 6 - 2 | 7 - 3 | 1 - 4 | 2 - 5 |
4 | 4 - 5 | 5 - 6 | 6 - 7 | 7 - 1 | 1 - 2 | 2 - 3 | 3 - 4 |
1 | import java.io.*; |
2 | import java.awt.*; |
3 | import java.awt.event.*; |
4 | class GestoreFinestra implements WindowListener { |
5 | public void windowIconified(WindowEvent e) {} |
6 | public void windowDeiconified(WindowEvent e){} |
7 | public void windowActivated(WindowEvent e){} |
8 | public void windowDeactivated(WindowEvent e){} |
9 | public void windowOpened(WindowEvent e){} |
10 | public void windowClosed(WindowEvent e){} |
11 | public void windowClosing(WindowEvent e){ |
12 | System.exit(0); |
13 | } |
14 | } |
1 | import java.io.*; |
2 | import java.awt.*; |
3 | import java.awt.event.*; |
4 | class GestoreFinestra implements WindowListener { |
5 | public void windowIconified(WindowEvent e) {} |
6 | public void windowDeiconified(WindowEvent e){} |
7 | public void windowActivated(WindowEvent e){} |
8 | public void windowDeactivated(WindowEvent e){} |
9 | public void windowOpened(WindowEvent e){} |
10 | public void windowClosed(WindowEvent e){} |
11 | public void windowClosing(WindowEvent e){ |
12 | System.exit(0); |
13 | } |
14 | } |
1 | class Squadre extends Frame implements KeyListener, ActionListener { |
2 | private int NrSquadre; |
3 | private String NomiSq[] = new String[16]; |
4 | private Panel p = new Panel(); |
5 | private TextArea risultati = new TextArea(15,30); |
6 | public Label Righe = new Label("0 Squadre"); |
7 | private Button Pulsante = new Button("Fine"); |
8 | public void keyPressed(KeyEvent e) {} |
9 | public void keyReleased(KeyEvent e) { |
10 | if (e.getKeyCode() == KeyEvent.VK_ENTER) { |
11 | risultati.append("-"); |
12 | ++NrSquadre; |
13 | Righe.setText(NrSquadre + " Squadre"); |
14 | } |
15 | } |
Quesito
Compattare il codice del metodo keyReleased integrando l'istruzione della linea 12 nell'istruzione della linea 13.
|
16 | public void keyTyped(KeyEvent e) { } |
17 | public Squadre() { |
18 | NrSquadre = 0; |
19 | p.add(risultati); |
20 | p.add(Pulsante); |
21 | p.add(Righe); |
22 | risultati.addKeyListener(this); |
23 | addWindowListener(new GestoreFinestra()); |
24 | Pulsante.addActionListener(this); |
25 | add(p); |
26 | risultati.setEditable(true); |
27 | } |
28 | public void actionPerformed(ActionEvent e) { |
29 | NomiSq = risultati.getText().split("-"); |
30 | if (NrSquadre>0) { |
31 | Righe.setText(NomiSq[--NrSquadre]); |
32 | } |
33 | } |
34 | } |
35 | class ElencoSq { |
36 | public static void main(String[] args) { |
37 | Squadre t = new Squadre(); |
38 | t.pack(); |
39 | t.setVisible(true); |
40 | } |
41 | } |
private static String NomiSq[] = new String[16]; |