Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. import java.io.*;
  2.  
  3. public class myThread extends Thread{
  4. votiStudente vs;
  5. ObjectOutputStream st = null;
  6. public myThread (votiStudente v) {
  7. this.vs = v;
  8. }
  9. public void run() {
  10. try {
  11. st = new ObjectOutputStream(new FileOutputStream("dati.dat"));
  12.  
  13. }catch(Exception e){
  14. System.out.println(e);
  15. System.out.println("Serializzazione completata");
  16. }
  17. }
  18. }
  19.  
  20.  
  21.  
  22. import java.io.Serializable;
  23. public class Voti implements Serializable{
  24. private static final long SerialVersionUID = 1;
  25. public float punteggio;
  26. public String data;
  27. public Voti (String nome, String cognome){
  28. this.punteggio = punteggio;
  29. this.data = data;
  30. }
  31.  
  32. }
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47. import java.io.*;
  48. import java.util.ArrayList;
  49. import java.util.Collection;
  50. public class votiStudente implements Serializable{
  51. private static final long serialVersionUID = 1;
  52. public String nome;
  53. public String cognome;
  54.  
  55. private Collection<Voti>voto;
  56. public votiStudente (String nome, String Cognome){
  57. this.nome = nome;
  58. this.cognome = cognome;
  59. voto = new ArrayList<Voti>();
  60. }
  61. public void aggiungiVoto(Voti a){
  62. voto.add(a);
  63. }
  64. public String toString(){
  65. String result = null;
  66. result= nome + " " + cognome + "" ;
  67. for (Voti v:voto){
  68. result = result + v.punteggio +" " + v.data + "; ";
  69. }
  70. return result;
  71. }
  72. public float media() {
  73. float somma = 0;
  74. float nVoti = 0;
  75. for (Voti v:voto){
  76. somma = somma + v.punteggio;
  77. nVoti++;
  78. }
  79. return somma/nVoti;
  80. }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement