Advertisement
Guest User

Untitled

a guest
Jan 26th, 2020
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. class Osoba{
  4. String imie;
  5. String nazwisko;
  6. int pesel;
  7.  
  8. public Osoba(){
  9. imie = "";
  10. nazwisko = "";
  11. pesel = 0;
  12. }
  13.  
  14. public Osoba(String i, String n, int w){
  15. imie = i;
  16. nazwisko = n;
  17. pesel = w;
  18. }
  19. }
  20.  
  21. class Student extends Osoba{
  22. int nr_indeksu;
  23. }
  24.  
  25. class Rencista extends Osoba {
  26. int wyplata;
  27. }
  28.  
  29.  
  30.  
  31. public class Main{
  32.  
  33. public static void main(String args[]){
  34. Osoba osoba = new Osoba("Wlodek", "Zięba", 3333333);
  35. System.out.println("Imię: "+osoba.imie);
  36. System.out.println("Nazwisko: "+osoba.nazwisko);
  37. System.out.println("Pesel: "+osoba.pesel+"\n");
  38.  
  39. Student Student = new Student();
  40. Student student1 = new Student();
  41. Student student2 = new Student();
  42.  
  43.  
  44. Student.imie = "Tadeusz";
  45. Student.nazwisko = "Kowalski";
  46. Student.pesel = 1111111;
  47. Student.nr_indeksu = 222222;
  48. System.out.println("Imię: "+Student.imie);
  49. System.out.println("Nazwisko: "+Student.nazwisko);
  50. System.out.println("Pesel: "+Student.pesel);
  51. System.out.println("nr_indeksu: "+Student.nr_indeksu);
  52.  
  53. Rencista rencista1 = new Rencista();
  54.  
  55. rencista1.imie = "Adrian";
  56. rencista1.nazwisko = "Polak";
  57. rencista1.pesel = 2222222;
  58. rencista1.wyplata = 1000;
  59.  
  60. List<Student> studenci = new ArrayList<>();
  61. studenci.add(Student);
  62. studenci.add(student1);
  63. studenci.add(student2);
  64. for(int i = 0; i < studenci.size(); i++) {
  65. System.out.println(studenci.get(i).imie);
  66. System.out.println(studenci.get(i).nazwisko);
  67. System.out.println(studenci.get(i).pesel);
  68. }
  69.  
  70. List<Student> rencisci = new ArrayList<>();
  71. for(int i = 0; i < rencisci.size(); i++) {
  72. System.out.println(rencisci.get(i).imie);
  73. System.out.println(rencisci.get(i).nazwisko);
  74. System.out.println(rencisci.get(i).pesel);
  75. }
  76.  
  77. }
  78.  
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement