Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- public class Università {
- public static void visualizzaAmmessi(Cella top)
- {
- if(top!=null)
- {
- System.out.print(top.getMatricola()+"\n");
- visualizzaAmmessi(top.next);
- }
- }
- public static Studente cercaStudente(String matricola, Studente []studenti)
- {
- Studente st=null;
- for(int i=0;i<studenti.length;i++)
- {
- if(studenti[i].getMatricola().compareTo(matricola)==0)
- st=studenti[i];
- }
- return st;
- }
- public static void main(String []args)
- {
- ConsoleReader console=new ConsoleReader();
- Professore prof=new Professore("Giuseppe","Rossi","Informatica");
- //creazione array di studenti di un corso
- Studente [] studenti=new Studente[5];
- for(int i=0;i<studenti.length;i++)
- {
- String nome="",cognome="",matricola="";
- nome+=(char)(97+Math.random()*21);
- cognome+=(char)(97+Math.random()*21);
- matricola+=(char)(97+Math.random()*21);
- studenti[i]=new Studente(nome,cognome,matricola,(short)10);
- }
- //convocazioni
- int i=0;
- StackD ammessi=new StackD();
- while(i<studenti.length)
- {
- System.out.println("vuoi convocare lo studente "+studenti[i].getCognome()+"? [Y/N]");
- char ch= console.readChar();
- if(ch=='y' || ch=='Y')
- {
- ammessi.push(studenti[i].getMatricola());
- i++;
- }
- else
- {
- if(ch=='n' || ch=='N')
- i++;
- }
- }
- //studenti ammessi
- System.out.println("\nelenco ammessi");
- visualizzaAmmessi(ammessi.top);
- //gestione votazioni
- while(ammessi.top!=null)
- {
- System.out.print("vuoi promuovere lo studente "+ammessi.top.getMatricola()+"? [Y/N]");
- char ch= console.readChar();
- if(ch=='y' || ch=='Y') //search ti deve ritornare l'eventuale studente al quale convalidare la materia
- {
- System.out.print("che votazione vuoi dare allo studente "+ammessi.top.getMatricola());
- short punteggio= console.readShort();
- boolean lode=false;
- if(punteggio==30)
- {
- System.out.print("vuoi dare la lode allo studente "+ammessi.top.getMatricola()+"? [Y/N]");
- char ld= console.readChar();
- if(ch=='y' || ch=='Y')
- lode=true;
- }
- String materia=prof.getMateria();
- Esame esame=new Esame(materia,punteggio,lode);
- cercaStudente(ammessi.top.getMatricola(),studenti).esamiSost.push(esame);
- ammessi.pop();
- }
- else
- {
- if(ch=='n' || ch=='N')
- ammessi.pop();
- }
- }
- console.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment