Advertisement
Todorov99

Untitled

Oct 14th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.37 KB | None | 0 0
  1. package Persno;
  2.  
  3. public class TestPerson {
  4.    
  5.     public static void nameOfEverything(Student[] arr1, Teacher[] arr2, Course[] arr, int num) {
  6.        
  7.         for(int i = 0; i < arr.length; i++) {
  8.             if(arr[i].getNumber() == num) {
  9.                
  10.                 System.out.println("" + arr1[i] + arr2[i] + arr[i]);
  11.             }
  12.        
  13.         }
  14.     }
  15.     public static void main(String[] args) {
  16.        
  17.        
  18.     Course[] school = new Course[3];
  19.     Teacher[] teach = new Teacher[3];
  20.     Student[] buddy = new Student[3];
  21.    
  22.    
  23.     Course student1 = new Course("Mat", 5);
  24.     Course student2 = new Course("Bel", 4);
  25.     Course student3 = new Course("Geografiq", 7);
  26.    
  27.     school[0] = student1;
  28.     school[1] = student2;
  29.     school[2] = student3;
  30.    
  31.    
  32.     Teacher teach1 = new Teacher("Georgi", "60021", school);
  33.     Teacher teach2 = new Teacher("Ivan", "996", school);
  34.     Teacher teach3 = new Teacher("Petkan", "6598", school);
  35.    
  36.     teach[0] = teach1;
  37.     teach[1] = teach2;
  38.     teach[2] = teach3;
  39.    
  40.     Student budy1 = new Student("Petar Petrov", "854786", "56485200");
  41.     Student budy2 = new Student("Georgi Dragiv", "87546", "56485200");
  42.     Student budy3 = new Student("Petkan Petkanov", "80231", "56485200");
  43.    
  44.    
  45.     buddy[0] = budy1;
  46.     buddy[1] = budy2;
  47.     buddy[2] = budy3;
  48.    
  49.     for(int i = 0; i < school.length; i++) {
  50.        
  51.         System.out.println("" + buddy[i] + teach[i] + school[i]);
  52.     }
  53.    
  54.     System.out.println("");
  55.    
  56.     nameOfEverything(buddy, teach, school, 7);
  57.    
  58.    
  59.  }
  60.    
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement