Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- public class myThread extends Thread{
- votiStudente vs;
- ObjectOutputStream st = null;
- public myThread (votiStudente v) {
- this.vs = v;
- }
- public void run() {
- try {
- st = new ObjectOutputStream(new FileOutputStream("dati.dat"));
- }catch(Exception e){
- System.out.println(e);
- System.out.println("Serializzazione completata");
- }
- }
- }
- import java.io.Serializable;
- public class Voti implements Serializable{
- private static final long SerialVersionUID = 1;
- public float punteggio;
- public String data;
- public Voti (String nome, String cognome){
- this.punteggio = punteggio;
- this.data = data;
- }
- }
- import java.io.*;
- import java.util.ArrayList;
- import java.util.Collection;
- public class votiStudente implements Serializable{
- private static final long serialVersionUID = 1;
- public String nome;
- public String cognome;
- private Collection<Voti>voto;
- public votiStudente (String nome, String Cognome){
- this.nome = nome;
- this.cognome = cognome;
- voto = new ArrayList<Voti>();
- }
- public void aggiungiVoto(Voti a){
- voto.add(a);
- }
- public String toString(){
- String result = null;
- result= nome + " " + cognome + "" ;
- for (Voti v:voto){
- result = result + v.punteggio +" " + v.data + "; ";
- }
- return result;
- }
- public float media() {
- float somma = 0;
- float nVoti = 0;
- for (Voti v:voto){
- somma = somma + v.punteggio;
- nVoti++;
- }
- return somma/nVoti;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement