Advertisement
Guest User

Untitled

a guest
Mar 28th, 2020
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.34 KB | None | 0 0
  1. package university;
  2. public class University {
  3. private String universityname;
  4. private String rectorName;
  5. private Student Students[] = new Student[1000];
  6. private Corso corso[] = new Corso[50];
  7. private int nstud = 0, ncorso=0, k;
  8. //private String listaIscritti;
  9. public University(String name){
  10. universityname = name;
  11. }
  12. public String getName(){
  13. return universityname;
  14. }
  15. public void setRector(String first, String last){
  16. rectorName= first + " " + last;
  17. }
  18. public String getRector(){
  19. return rectorName;
  20. }
  21. public int enroll(String first, String last){
  22. Student student = new Student(first, last, nstud+10000);
  23. Students[nstud] = student;
  24. nstud++;
  25. return Students[nstud-1].getID();
  26. }
  27. public String student(int id){
  28. int n=id-10000;
  29. String export = id + " " + Students[n].getNome() + " " + Students[n].getCognome();
  30. return export;
  31. }
  32. public int activate(String title, String teacher){
  33. Corso cor = new Corso(title, teacher, ncorso+10);
  34. corso[ncorso]= cor;
  35. ncorso++;
  36. return corso[ncorso-1].getCodiceCorso();
  37. }
  38. public String course(int code){
  39. k=code-10;
  40. return corso[k].getCodiceCorso() + "," + corso[k].getNomeCorso() + "," + corso[k].getNomeProf();
  41. }
  42. public void register(int studentID, int courseCode){
  43. Students[studentID-10000].addMateria(courseCode);
  44. corso[courseCode-10].addIscritto(studentID);
  45. }
  46. public String listAttendees(int courseCode){
  47. int niscr= corso[courseCode-10].getI();
  48. int f=0;
  49. String export1="";
  50. for (f=0; f<=niscr; f++)
  51. {
  52. System.out.println(export1);
  53. export1+=student(f+10000)+"\n";
  54. }
  55. return export1;
  56. }
  57.  
  58. /**
  59. * Retrieves the study plan for a student
  60. *
  61. * @param studentID id of the student
  62. * @return list of courses the student is registered for
  63. */
  64. public String studyPlan(int studentID){
  65. //TODO: to be implemented
  66. return null;
  67. }
  68. public class Student {
  69.  
  70. private String nome, cognome;
  71. private int ID;
  72. private int[] carico=new int[25];
  73. private int i=0;
  74. public Student (String first, String last, int mat) {
  75. nome=first;
  76. cognome=last;
  77. ID= mat;
  78. }
  79. public void addMateria(int codice) {
  80. carico[i]=codice;
  81. i++;
  82. }
  83. public String getNome() {
  84. return nome;
  85. }
  86. public void setNome(String nome) {
  87. this.nome = nome;
  88. }
  89. public String getCognome() {
  90. return cognome;
  91. }
  92. public void setCognome(String cognome) {
  93. this.cognome = cognome;
  94. }
  95. public int getID() {
  96. return ID;
  97. }
  98. public void setID(int iD) {
  99. ID = iD;
  100. }
  101.  
  102. }
  103. public class Corso {
  104. private String nomeCorso, nomeProf;
  105. private int codiceCorso;
  106. private int i=0, j;
  107. private int[] iscritti= new int[100];
  108. public Corso (String title, String teacher, int code)
  109. {
  110. nomeCorso= title;
  111. nomeProf= teacher;
  112. codiceCorso=code;
  113. }
  114. public void addIscritto(int ID) {
  115. iscritti[i]=ID;
  116. i++;
  117. }
  118. public String getNomeCorso() {
  119. return nomeCorso;
  120. }
  121. public void setNomeCorso(String nomeCorso) {
  122. this.nomeCorso = nomeCorso;
  123. }
  124. public String getNomeProf() {
  125. return nomeProf;
  126. }
  127. public void setNomeProf(String nomeProf) {
  128. this.nomeProf = nomeProf;
  129. }
  130. public int getCodiceCorso() {
  131. return codiceCorso;
  132. }
  133. public void setCodiceCorso(int codiceCorso) {
  134. this.codiceCorso = codiceCorso;
  135. }
  136. public int getI() {
  137. return i;
  138. }
  139. }
  140. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement