Guest User

Untitled

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