Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Main {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- String n = scan.nextLine();
- Teachers tch1 = new Teachers("Boril Spasov");
- Teachers tch2 = new Teachers("Nikolai Emilov");
- Teachers tch3 = new Teachers("Rocky Balboa");
- tch1.subjects.add(new Subject("Maths", 40, 13));
- tch2.subjects.add(new Subject("English", 30, 20));
- tch3.subjects.add(new Subject("Physical Education", 20, 10));
- Students st1 = new Students("Kiril Ivanov", 14);
- Students st2 = new Students("David Emilov", 18);
- Students st3 = new Students("Katq Rumenova", 19);
- Students st4 = new Students("Rosica Naidenova", 5);
- Classes c1 = new Classes("Maths Class");
- c1.teacher.add(tch1);
- c1.students.add(st1);
- c1.students.add(st3);
- Classes c2 = new Classes("English Class");
- c2.teacher.add(tch2);
- c2.students.add(st1);
- c2.students.add(st4);
- Classes c3 = new Classes("Physical Education Class");
- c3.teacher.add(tch3);
- c3.students.add(st2);
- c3.students.add(st4);
- if (n.equalsIgnoreCase("Maths Class")) {
- c1.printClass();
- c1.printTeach();
- c1.printStud();
- } else if (n.equalsIgnoreCase("English Class")) {
- c2.printClass();
- c2.printTeach();
- c2.printStud();
- } else if (n.equalsIgnoreCase("Physical Education Class")) {
- c3.printClass();
- c3.printTeach();
- c3.printStud();
- } else {
- System.out.println("There is no classes like this!!");
- }
- }
- }
- \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
- public class Subject {
- private String name;
- private int lessons;
- private int ex;
- public String getName() {
- return name;
- }
- public Subject(String name, int lessons, int ex) {
- this.name = name;
- this.lessons = lessons;
- this.ex = ex;
- }
- }
- \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
- import java.util.*;
- public class Teachers {
- private String name;
- public ArrayList<Subject> subjects = new ArrayList<Subject>();
- public String getName() {
- return name;
- }
- public Teachers(String name) {
- this.name = name;
- }
- }
- \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
- import java.util.*;
- public class Classes {
- private String name;
- public ArrayList<Teachers> teacher = new ArrayList<Teachers>();
- public ArrayList<Students> students = new ArrayList<Students>();
- public Classes(String name) {
- this.name = name;
- }
- public void printStud() {
- System.out.println("\nStudents");
- for (Students s : this.students) {
- System.out.println("Name: " + s.getName() + " " + s.getNum());
- }
- }
- public void printTeach() {
- System.out.println("\nTeacher");
- for (Teachers t : this.teacher) {
- System.out.println("Name: " + t.getName());
- }
- }
- public void printClass() {
- System.out.println(this.name);
- }
- }
- \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
- public class Students {
- public Students(String name, int num) {
- this.name = name;
- this.num = num;
- }
- private String name;
- private int num;
- public String getName() {
- return name;
- }
- public int getNum() {
- return num;
- }
- }
- \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement