Advertisement
Dido09

4.4 - School

May 8th, 2019
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.26 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class Main {
  4.  
  5. public static void main(String[] args) {
  6. Scanner scan = new Scanner(System.in);
  7. String n = scan.nextLine();
  8.  
  9. Teachers tch1 = new Teachers("Boril Spasov");
  10. Teachers tch2 = new Teachers("Nikolai Emilov");
  11. Teachers tch3 = new Teachers("Rocky Balboa");
  12. tch1.subjects.add(new Subject("Maths", 40, 13));
  13. tch2.subjects.add(new Subject("English", 30, 20));
  14. tch3.subjects.add(new Subject("Physical Education", 20, 10));
  15.  
  16. Students st1 = new Students("Kiril Ivanov", 14);
  17. Students st2 = new Students("David Emilov", 18);
  18. Students st3 = new Students("Katq Rumenova", 19);
  19. Students st4 = new Students("Rosica Naidenova", 5);
  20.  
  21. Classes c1 = new Classes("Maths Class");
  22. c1.teacher.add(tch1);
  23. c1.students.add(st1);
  24. c1.students.add(st3);
  25.  
  26. Classes c2 = new Classes("English Class");
  27. c2.teacher.add(tch2);
  28. c2.students.add(st1);
  29. c2.students.add(st4);
  30.  
  31. Classes c3 = new Classes("Physical Education Class");
  32. c3.teacher.add(tch3);
  33. c3.students.add(st2);
  34. c3.students.add(st4);
  35.  
  36. if (n.equalsIgnoreCase("Maths Class")) {
  37. c1.printClass();
  38. c1.printTeach();
  39. c1.printStud();
  40. } else if (n.equalsIgnoreCase("English Class")) {
  41. c2.printClass();
  42. c2.printTeach();
  43. c2.printStud();
  44. } else if (n.equalsIgnoreCase("Physical Education Class")) {
  45. c3.printClass();
  46. c3.printTeach();
  47. c3.printStud();
  48. } else {
  49. System.out.println("There is no classes like this!!");
  50. }
  51.  
  52. }
  53.  
  54. }
  55. \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  56.  
  57. public class Subject {
  58.  
  59. private String name;
  60. private int lessons;
  61. private int ex;
  62.  
  63. public String getName() {
  64. return name;
  65. }
  66.  
  67. public Subject(String name, int lessons, int ex) {
  68. this.name = name;
  69. this.lessons = lessons;
  70. this.ex = ex;
  71. }
  72.  
  73. }
  74. \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  75.  
  76.  
  77. import java.util.*;
  78.  
  79. public class Teachers {
  80.  
  81. private String name;
  82. public ArrayList<Subject> subjects = new ArrayList<Subject>();
  83.  
  84. public String getName() {
  85. return name;
  86. }
  87.  
  88. public Teachers(String name) {
  89. this.name = name;
  90. }
  91.  
  92. }
  93. \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  94.  
  95.  
  96. import java.util.*;
  97.  
  98. public class Classes {
  99.  
  100. private String name;
  101. public ArrayList<Teachers> teacher = new ArrayList<Teachers>();
  102. public ArrayList<Students> students = new ArrayList<Students>();
  103.  
  104. public Classes(String name) {
  105. this.name = name;
  106. }
  107.  
  108. public void printStud() {
  109. System.out.println("\nStudents");
  110. for (Students s : this.students) {
  111. System.out.println("Name: " + s.getName() + " " + s.getNum());
  112. }
  113. }
  114.  
  115. public void printTeach() {
  116. System.out.println("\nTeacher");
  117. for (Teachers t : this.teacher) {
  118. System.out.println("Name: " + t.getName());
  119. }
  120. }
  121.  
  122. public void printClass() {
  123. System.out.println(this.name);
  124. }
  125.  
  126. }
  127. \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  128.  
  129.  
  130. public class Students {
  131.  
  132. public Students(String name, int num) {
  133. this.name = name;
  134. this.num = num;
  135. }
  136.  
  137. private String name;
  138. private int num;
  139.  
  140. public String getName() {
  141. return name;
  142. }
  143.  
  144. public int getNum() {
  145. return num;
  146. }
  147.  
  148. }
  149.  
  150. \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement