cerca
ProvaJava
modifica cronologia stampa login logout

Wiki

Tools

Categorie

Help

edit SideBar

Return to Prova Java  (Edit)

Utenti.ProvaJava History

Hide minor edits - Show changes to markup

Changed lines 1-96 from:

public class Televisore {

    private boolean AS;
    private int canale;
    private int volume;
    private String nomeCanale;
    String listaCanali[] = {"RaiUno", "RaiDue", "RaiTre", "Italia1", "Canale5", "Rete4", "La7", "TRS", "MTV"};

    public Televisore() {

        this.AS = false;
        this.canale = 1;
        this.volume = 0;



    }

    public boolean AccesoSpento(boolean pulsanteAS) {
        if (pulsanteAS == true) {
            this.AS = true;
            return (this.AS);
        }
        else {
            this.AS = false;
            return (this.AS);
        }
    }

    public void AlzaVolume() {

        if (this.AS == true) {
            if (this.volume < 100) {

                this.volume++;
            }
            else {

                System.out.println("Il volume è già al massimo");
            }
        }
        else {

            System.out.println("Pirla! Guardi la tv anche se è spenta?");
        }
    }

    public void AbbassaVolume() {
        if (this.AS == true) {
            if (this.volume == 0) {

                System.out.println("Il volume è già al minimo");

            }
            else {

                this.volume--;
            }
        }
        else {

            System.out.println("Pirla! Guardi la tv anche se è spenta?");
        }
    }

    public String CambiaCanale(int numeroCanale) {

        if (!this.AS) {
            return ("La televisione non è accesa...pirla!");
        }

        if (numeroCanale < 9 && numeroCanale >= 1) {

            this.nomeCanale = this.listaCanali[numeroCanale - 1];
            return (this.nomeCanale);

        }
        else {
            return ("Il canale non esiste");
        }
    }

    public void StatoTV() {
        if (this.AS == true) {
            System.out.println("La tv è accesa");
            System.out.println("Il canale è " + this.nomeCanale);
            System.out.println("Il volume è a " + this.volume);

        }
        else {
            System.out.println("La tv è spenta");

        }


    }
to:

public class Ellisse {

  // variabili istanza
  private double asseMaggiore, asseMinore;

  // costruttori
  public Ellisse() {
    this.asseMaggiore = 0.0;
    this.asseMinore = 0.0;
  }

  public Ellisse(double maggiore, double minore) {
    this.asseMaggiore = maggiore;
    this.asseMinore = minore;
  }

  // metodi istanza
  public void setAsseMaggiore(double maggiore) {
    this.asseMaggiore = maggiore;
  }

  public void setAsseMinore(double minore) {
    this.asseMinore = minore;
  }

  public double getAsseMaggiore() {
    return this.asseMaggiore;
  }

  public double getAsseMinore() {
    return this.asseMinore;
  }

  public double calcolaArea() {
    return Math.PI * this.asseMaggiore * this.asseMinore;
  }
Changed lines 40-73 from:

Ecco, se vuoi provare :)

to:

public class Cerchio extends Ellisse {

   public Cerchio(double raggio) {
    // Invochiamo direttamente un costruttore specifico della superclasse, 
    // imponendo che asseMinore = asseMinore = raggio. 
    // Ricordate che questa istruzione deve essere il primo enunciato del 
    // costruttore della sottoclasse perchè altrimenti, la JVM invoca al posto
    // vostro come prima istruzione super();
    super(raggio,raggio);
  }

  // metodi istanza

// public void setRaggio(double raggio) { // this.setAsseMaggiore(raggio); // this.setAsseMinore(raggio); // }

  public double getRaggio() {
    return this.getAsseMaggiore();
  }

public class AreaEllisse {

    public static void main(String[] args) {
    String stringaInput;
    stringaInput = JOptionPane.showInputDialog("Inserisci il raggio: ");
    Cerchio cerchioUtente = new Cerchio(Double.parseDouble(stringaInput));

    JOptionPane.showMessageDialog(null, "L'area del cerchio avente raggio " +
      cerchioUtente.getRaggio() + "è " + cerchioUtente.calcolaArea());

    System.exit(0);
  }

}

Added line 6:
    private String nomeCanale;
Changed line 23 from:
        } 
to:
        }
Changed line 36 from:
            } 
to:
            }
Changed line 41 from:
        } 
to:
        }
Changed line 54 from:
            } 
to:
            }
Changed line 59 from:
        } 
to:
        }
Changed lines 74-76 from:
            return (this.listaCanali[numeroCanale - 1]);

        } 
to:
            this.nomeCanale = this.listaCanali[numeroCanale - 1];
            return (this.nomeCanale);

        }
Changed lines 86-89 from:
            System.out.println(this.canale);
            System.out.println("Il volume è " + this.volume);

        } 
to:
            System.out.println("Il canale è " + this.nomeCanale);
            System.out.println("Il volume è a " + this.volume);

        }
Added line 92:
Changed lines 97-100 from:

}

to:

}

Ecco, se vuoi provare :)

Changed line 6 from:
    String listaCanali[] = {"RaiUno", "RaiDue", "RaiTre", "Italia1", "Canale5",\\ "Rete4", "La7", "TRS", "MTV"};
to:
    String listaCanali[] = {"RaiUno", "RaiDue", "RaiTre", "Italia1", "Canale5", "Rete4", "La7", "TRS", "MTV"};
Changed line 6 from:
    String listaCanali[] = {"RaiUno", "RaiDue", "RaiTre", "Italia1", "Canale5", "Rete4", "La7", "TRS", "MTV"};
to:
    String listaCanali[] = {"RaiUno", "RaiDue", "RaiTre", "Italia1", "Canale5",\\ "Rete4", "La7", "TRS", "MTV"};
Changed lines 6-7 from:
     private int canaleCorrente;
to:
    String listaCanali[] = {"RaiUno", "RaiDue", "RaiTre", "Italia1", "Canale5", "Rete4", "La7", "TRS", "MTV"};
Changed lines 13-15 from:
         this.canaleCorrente = 1;
to:
Changed lines 22-23 from:
        } else {
to:
        } 
        else {
Changed lines 35-36 from:
            } else {
to:
            } 
            else {
Changed lines 40-41 from:
        } else {
to:
        } 
        else {
Changed lines 53-54 from:
            } else {
to:
            } 
            else {
Changed lines 58-59 from:
        } else {
to:
        } 
        else {
Changed lines 65-68 from:
    public void CambiaCanale(int numeroCanale) {
to:
    public String CambiaCanale(int numeroCanale) {
Changed lines 68-69 from:
            System.out.println("La televisione non è accesa...pirla!");
            return;
to:
            return ("La televisione non è accesa...pirla!");
Changed lines 71-103 from:
         canaleCorrente = numeroCanale;

        switch (numeroCanale) {
            case 1:
                System.out.println("Raiuno");
                break;
            case 2:
                System.out.println("Raidue");
                break;
            case 3:
                System.out.println("Raitre");
                break;
            case 4:
                System.out.println("Italia1");
                break;
            case 5:
                System.out.println("Canale5");
                break;
            case 6:
                System.out.println("Rete4");
                break;
            case 7:
                System.out.println("La7");
                break;
            case 8:
                System.out.println("TRS");
                break;
            case 9:
                System.out.println("MTV");
                break;
            default:
                System.out.println("Il canale " + numeroCanale + " non esiste!");
to:
        if (numeroCanale < 9 && numeroCanale >= 1) {

            return (this.listaCanali[numeroCanale - 1]);

        } 
        else {
            return ("Il canale non esiste");
Changed lines 84-86 from:
            System.out.println(canaleCorrente);

        } else {
to:
            System.out.println(this.canale);
            System.out.println("Il volume è " + this.volume);

        } 
        else {
Changed lines 6-7 from:
    int canaleCorrente;
to:
     private int canaleCorrente;
Changed lines 13-15 from:
to:
         this.canaleCorrente = 1;
Changed lines 62-63 from:
        canaleCorrente = numeroCanale;
to:
Added lines 68-69:
         canaleCorrente = numeroCanale;
Changed lines 1-112 from:

Prova Java

to:

public class Televisore {

    private boolean AS;
    private int canale;
    private int volume;
    int canaleCorrente;

    public Televisore() {

        this.AS = false;
        this.canale = 1;
        this.volume = 0;

    }

    public boolean AccesoSpento(boolean pulsanteAS) {
        if (pulsanteAS == true) {
            this.AS = true;
            return (this.AS);
        } else {
            this.AS = false;
            return (this.AS);
        }
    }

    public void AlzaVolume() {

        if (this.AS == true) {
            if (this.volume < 100) {

                this.volume++;
            } else {

                System.out.println("Il volume è già al massimo");
            }
        } else {

            System.out.println("Pirla! Guardi la tv anche se è spenta?");
        }
    }

    public void AbbassaVolume() {
        if (this.AS == true) {
            if (this.volume == 0) {

                System.out.println("Il volume è già al minimo");

            } else {

                this.volume--;
            }
        } else {

            System.out.println("Pirla! Guardi la tv anche se è spenta?");
        }
    }

    public void CambiaCanale(int numeroCanale) {

        canaleCorrente = numeroCanale;

        if (!this.AS) {
            System.out.println("La televisione non è accesa...pirla!");
            return;
        }

        switch (numeroCanale) {
            case 1:
                System.out.println("Raiuno");
                break;
            case 2:
                System.out.println("Raidue");
                break;
            case 3:
                System.out.println("Raitre");
                break;
            case 4:
                System.out.println("Italia1");
                break;
            case 5:
                System.out.println("Canale5");
                break;
            case 6:
                System.out.println("Rete4");
                break;
            case 7:
                System.out.println("La7");
                break;
            case 8:
                System.out.println("TRS");
                break;
            case 9:
                System.out.println("MTV");
                break;
            default:
                System.out.println("Il canale " + numeroCanale + " non esiste!");

        }
    }

    public void StatoTV() {
        if (this.AS == true) {
            System.out.println("La tv è accesa");
            System.out.println(canaleCorrente);

        } else {
            System.out.println("La tv è spenta");
        }


    }

}

Added line 1:

Prova Java