Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package javaapplication2;
  7.  
  8. /**
  9. *
  10. * @author student
  11. */
  12. public class JavaApplication2 {
  13.  
  14. /**
  15. * @param args the command line arguments
  16. */
  17. public static void main(String[] args) {
  18. // TODO code application logic here
  19. Profesor poo = new Profesor("poo","prof_poo");
  20. Student ghita = new Student(7,"ghita");
  21. System.out.println(poo);
  22. System.out.println(ghita);
  23. Persoana[] v = new Persoana[10];
  24. System.out.println("\n");
  25. v[0] = new Persoana("ada");
  26. v[1] = new Profesor("AA","insertname");
  27. v[2] = new Student(6,"bogdan");
  28. for(int i = 0; i< 3; i++)
  29. {
  30. System.out.println(v[i]);
  31. }
  32. System.out.println("\n");
  33. for(int i = 0; i < 3; i++)
  34. {
  35. if(v[i] instanceof Profesor)
  36. ((Profesor)v[i]).preda();
  37. if(v[i] instanceof Student)
  38. ((Student)v[i]).invata();
  39. }
  40. }
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement