Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- class Osoba{
- String imie;
- String nazwisko;
- int pesel;
- public Osoba(){
- imie = "";
- nazwisko = "";
- pesel = 0;
- }
- public Osoba(String i, String n, int w){
- imie = i;
- nazwisko = n;
- pesel = w;
- }
- }
- class Student extends Osoba{
- int nr_indeksu;
- }
- class Rencista extends Osoba {
- int wyplata;
- }
- public class Main{
- public static void main(String args[]){
- Osoba osoba = new Osoba("Wlodek", "Zięba", 3333333);
- System.out.println("Imię: "+osoba.imie);
- System.out.println("Nazwisko: "+osoba.nazwisko);
- System.out.println("Pesel: "+osoba.pesel+"\n");
- Student Student = new Student();
- Student student1 = new Student();
- Student student2 = new Student();
- Student.imie = "Tadeusz";
- Student.nazwisko = "Kowalski";
- Student.pesel = 1111111;
- Student.nr_indeksu = 222222;
- System.out.println("Imię: "+Student.imie);
- System.out.println("Nazwisko: "+Student.nazwisko);
- System.out.println("Pesel: "+Student.pesel);
- System.out.println("nr_indeksu: "+Student.nr_indeksu);
- Rencista rencista1 = new Rencista();
- rencista1.imie = "Adrian";
- rencista1.nazwisko = "Polak";
- rencista1.pesel = 2222222;
- rencista1.wyplata = 1000;
- List<Student> studenci = new ArrayList<>();
- studenci.add(Student);
- studenci.add(student1);
- studenci.add(student2);
- for(int i = 0; i < studenci.size(); i++) {
- System.out.println(studenci.get(i).imie);
- System.out.println(studenci.get(i).nazwisko);
- System.out.println(studenci.get(i).pesel);
- }
- List<Student> rencisci = new ArrayList<>();
- for(int i = 0; i < rencisci.size(); i++) {
- System.out.println(rencisci.get(i).imie);
- System.out.println(rencisci.get(i).nazwisko);
- System.out.println(rencisci.get(i).pesel);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement