Commit d3cc72e6 by Patryk Czarnik

Student - konstruktor

parent 3bc324d7
......@@ -55,5 +55,14 @@ public class Dziedziczenie1 {
Konto konto = new Konto(1, 3000, student);
System.out.println(konto);
System.out.println();
// Z nadklasy NIE SĄ dziedziczone konstruktory.
// Fakt, że w klasie Osoba istniał konstruktor (String, String, int)
// nie powoduje powstania analogicznego konstruktora w klasie Student.
// Student student2 = new Student("Adam", "Adamowski", 22);
Student student3 = new Student("Adam", "Adamowski", 22, "budownictwo", 3);
System.out.println(student3);
student3.przedstawSie();
}
}
......@@ -10,7 +10,6 @@ class Osoba {
}
Osoba() {
}
Osoba(String imie, String nazwisko, int wiek) {
......
......@@ -8,6 +8,15 @@ class Student extends Osoba {
int rok;
List<Integer> oceny = new ArrayList<>();
Student() {
}
public Student(String imie, String nazwisko, int wiek, String kierunek, int rok) {
super(imie, nazwisko, wiek);
this.kierunek = kierunek;
this.rok = rok;
}
void dodajOcene(int ocena) {
oceny.add(ocena);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment