Guest User

Università

a guest
May 2nd, 2013
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.49 KB | None | 0 0
  1.  
  2. import java.io.*;
  3. public class Università {
  4.     public static void visualizzaAmmessi(Cella top)
  5.     {
  6.         if(top!=null)
  7.         {
  8.             System.out.print(top.getMatricola()+"\n");
  9.             visualizzaAmmessi(top.next);
  10.         }
  11.     }
  12.     public static Studente cercaStudente(String matricola, Studente []studenti)
  13.     {
  14.         Studente st=null;
  15.             for(int i=0;i<studenti.length;i++)
  16.             {
  17.                 if(studenti[i].getMatricola().compareTo(matricola)==0)
  18.                     st=studenti[i];
  19.             }
  20.         return st;
  21.     }
  22.     public static void main(String []args)
  23.     {
  24.         ConsoleReader console=new ConsoleReader();
  25.         Professore prof=new Professore("Giuseppe","Rossi","Informatica");
  26.         //creazione array di studenti di un corso
  27.         Studente [] studenti=new Studente[5];
  28.             for(int i=0;i<studenti.length;i++)
  29.             {
  30.                 String nome="",cognome="",matricola="";
  31.                 nome+=(char)(97+Math.random()*21);
  32.                 cognome+=(char)(97+Math.random()*21);
  33.                 matricola+=(char)(97+Math.random()*21);
  34.                 studenti[i]=new Studente(nome,cognome,matricola,(short)10);
  35.             }
  36.         //convocazioni
  37.         int i=0;
  38.         StackD ammessi=new StackD();
  39.             while(i<studenti.length)
  40.             {
  41.                 System.out.print("vuoi convocare lo studente con matricola "+studenti[i].getMatricola()+"? [Y/N]");
  42.                 char ch= console.readChar();
  43.                     if(ch=='y' || ch=='Y')
  44.                     {
  45.                         ammessi.push(studenti[i].getMatricola());
  46.                         i++;
  47.                     }
  48.                     else
  49.                     {
  50.                         if(ch=='n' || ch=='N')
  51.                             i++;
  52.                     }
  53.             }
  54.         //studenti ammessi
  55.             System.out.println("\nelenco ammessi");
  56.             visualizzaAmmessi(ammessi.top);
  57.         //gestione votazioni
  58.             while(ammessi.top!=null)
  59.             {
  60.                 System.out.print("vuoi promuovere lo studente "+ammessi.top.getMatricola()+"? [Y/N]");
  61.                 char ch= console.readChar();
  62.                     if(ch=='y' || ch=='Y') //search ti deve ritornare l'eventuale studente al quale convalidare la materia
  63.                     {
  64.                         System.out.print("che votazione vuoi dare allo studente "+ammessi.top.getMatricola());
  65.                         short punteggio= console.readShort();
  66.                         boolean lode=false;
  67.                             if(punteggio==30)
  68.                             {
  69.                                 System.out.print("vuoi dare la lode allo studente "+ammessi.top.getMatricola()+"? [Y/N]");
  70.                                 char ld= console.readChar();
  71.                                     if(ch=='y' || ch=='Y')
  72.                                         lode=true;
  73.                             }
  74.                         String materia=prof.getMateria();
  75.                         Esame esame=new Esame(materia,punteggio,lode);
  76.                         cercaStudente(ammessi.top.getMatricola(),studenti).esamiSost.push(esame);
  77.                         ammessi.pop();
  78.                     }
  79.                     else
  80.                     {
  81.                         if(ch=='n' || ch=='N')
  82.                         ammessi.pop();
  83.                     }
  84.             }
  85.         console.close();
  86.     }  
  87. }
Advertisement
Add Comment
Please, Sign In to add comment