Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package university;
- public class University {
- private String universityname;
- private String rectorName;
- private Student Students[] = new Student[1000];
- private Corso corso[] = new Corso[50];
- private int nstud = 0, ncorso=0, k;
- //private String listaIscritti;
- public University(String name){
- universityname = name;
- }
- public String getName(){
- return universityname;
- }
- public void setRector(String first, String last){
- rectorName= first + " " + last;
- }
- public String getRector(){
- return rectorName;
- }
- public int enroll(String first, String last){
- Student student = new Student(first, last, nstud+10000);
- Students[nstud] = student;
- nstud++;
- return Students[nstud-1].getID();
- }
- public String student(int id){
- int n=id-10000;
- String export = id + " " + Students[n].getNome() + " " + Students[n].getCognome();
- return export;
- }
- public int activate(String title, String teacher){
- Corso cor = new Corso(title, teacher, ncorso+10);
- corso[ncorso]= cor;
- ncorso++;
- return corso[ncorso-1].getCodiceCorso();
- }
- public String course(int code){
- k=code-10;
- return corso[k].getCodiceCorso() + "," + corso[k].getNomeCorso() + "," + corso[k].getNomeProf();
- }
- public void register(int studentID, int courseCode){
- Students[studentID-10000].addMateria(courseCode);
- corso[courseCode-10].addIscritto(studentID);
- }
- public String listAttendees(int courseCode){
- int niscr= corso[courseCode-10].getI();
- int f=0;
- String export1="";
- for (f=0; f<=niscr; f++)
- {
- System.out.println(export1);
- export1+=student(f+10000)+"\n";
- }
- return export1;
- }
- /**
- * Retrieves the study plan for a student
- *
- * @param studentID id of the student
- * @return list of courses the student is registered for
- */
- public String studyPlan(int studentID){
- //TODO: to be implemented
- return null;
- }
- public class Student {
- private String nome, cognome;
- private int ID;
- private int[] carico=new int[25];
- private int i=0;
- public Student (String first, String last, int mat) {
- nome=first;
- cognome=last;
- ID= mat;
- }
- public void addMateria(int codice) {
- carico[i]=codice;
- i++;
- }
- public String getNome() {
- return nome;
- }
- public void setNome(String nome) {
- this.nome = nome;
- }
- public String getCognome() {
- return cognome;
- }
- public void setCognome(String cognome) {
- this.cognome = cognome;
- }
- public int getID() {
- return ID;
- }
- public void setID(int iD) {
- ID = iD;
- }
- }
- public class Corso {
- private String nomeCorso, nomeProf;
- private int codiceCorso;
- private int i=0, j;
- private int[] iscritti= new int[100];
- public Corso (String title, String teacher, int code)
- {
- nomeCorso= title;
- nomeProf= teacher;
- codiceCorso=code;
- }
- public void addIscritto(int ID) {
- iscritti[i]=ID;
- i++;
- }
- public String getNomeCorso() {
- return nomeCorso;
- }
- public void setNomeCorso(String nomeCorso) {
- this.nomeCorso = nomeCorso;
- }
- public String getNomeProf() {
- return nomeProf;
- }
- public void setNomeProf(String nomeProf) {
- this.nomeProf = nomeProf;
- }
- public int getCodiceCorso() {
- return codiceCorso;
- }
- public void setCodiceCorso(int codiceCorso) {
- this.codiceCorso = codiceCorso;
- }
- public int getI() {
- return i;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement