Advertisement
Guest User

Untitled

a guest
Oct 24th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. public class Student extends Człowiek {
  2.  
  3. public int rok;
  4. public String kierunek;
  5.  
  6.  
  7. public Student(){
  8. this.rok=1;
  9. this.kierunek="Ceramika";
  10. }
  11. public Student(int a,String kierunek){
  12. this.rok=a;
  13. this.kierunek=kierunek;
  14. }
  15. public Student(int a, String kierunek,int wiek){
  16. super(wiek);
  17. this.rok=a;
  18. this.kierunek=kierunek;
  19.  
  20. }
  21. public Student(int a,String kierunek, int wiek,String imie){
  22. super(imie,wiek);
  23. this.rok=a;
  24. this.kierunek=kierunek;
  25.  
  26. }
  27. public int getRok(){
  28. return rok;
  29. }
  30. public String getKierunek(){
  31. return kierunek;
  32. }
  33. public String toString(){
  34. return "Rok :" + this.rok + " kierunek : "+ this.kierunek +" "+super.toString();
  35. }
  36.  
  37. public static void main(String[] args) {
  38. Człowiek[] c = new Człowiek[5];
  39. c[0]= new Człowiek("Paweł",27);
  40. c[1]=new Student(2,"Informatyka",23,"Jan");
  41. c[2] =new Student(1,"Elektronika");
  42. c[3]=new Człowiek();
  43. c[4]=new Student(5,"Automatyka",25);
  44.  
  45. for(Człowiek x:c){
  46. System.out.println(x.toString());
  47. }
  48.  
  49.  
  50. }
  51.  
  52. }
  53.  
  54.  
  55. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  56.  
  57.  
  58.  
  59.  
  60. public class Człowiek {
  61.  
  62. public String imie;
  63. public int wiek;
  64.  
  65.  
  66. public Człowiek(){
  67. this.imie="Jacek";
  68. this.wiek=20;
  69. }
  70. public Człowiek(String a){
  71. this.imie=a;
  72. this.wiek=20;
  73. }
  74. public Człowiek(int a){
  75. this.imie="Jacek";
  76. this.wiek=a;
  77. }
  78. public Człowiek(String a, int x){
  79. this.imie=a;
  80. this.wiek=x;
  81. }
  82. public String getImie(){
  83. return imie;
  84. }
  85. public int getWiek(){
  86. return wiek;
  87. }
  88. public String toString(){
  89. return "To człowiek o imieniu : " + this.getImie() + " wiek: " + this.getWiek();
  90. }
  91.  
  92. public static void main(String[] args) {
  93.  
  94.  
  95. }
  96.  
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement