Commit 758283ce by Patryk Czarnik

oceny studenta - początek przykładu

parent 78748cdf
...@@ -11,7 +11,15 @@ public class Program { ...@@ -11,7 +11,15 @@ public class Program {
// gdybym chiał odczytać pola obiektu - nie mogę, bo są prywatne // gdybym chiał odczytać pola obiektu - nie mogę, bo są prywatne
System.out.println(ala.getImie() + " urodziła się w miesiącu " + ala.getDataUrodzenia().getMonth()); System.out.println(ala.getImie() + " urodziła się w miesiącu " + ala.getDataUrodzenia().getMonth());
System.out.println("wiek = " + ala.getWiek()); System.out.println("wiek = " + ala.getWiek());
System.out.println();
Student student = new Student("Jan", "Kowalski", "2002-02-02", "matematyka", 3);
System.out.println(student);
student.dodajOcene(3);
student.dodajOcene(3);
student.dodajOcene(5);
System.out.println("oceny: " + student.getOceny());
System.out.println("średnia: " + student.sredniaOcen());
} }
} }
package p11_klasy.enkapsulacja;
import java.time.LocalDate;
import java.util.List;
public class Student extends Osoba {
private String kierunek;
private int rok;
public Student(String imie, String nazwisko, LocalDate dataUrodzenia, String kierunek, int rok) {
super(imie, nazwisko, dataUrodzenia);
this.kierunek = kierunek;
this.rok = rok;
}
public Student(String imie, String nazwisko, String dataUrodzenia, String kierunek, int rok) {
super(imie, nazwisko, dataUrodzenia);
this.kierunek = kierunek;
this.rok = rok;
}
@Override
public String toString() {
return super.toString() + ", student " + rok + " roku kierunku " + kierunek;
}
public String getKierunek() {
return kierunek;
}
public int getRok() {
return rok;
}
public void dodajOcene(int ocena) {
// TODO
}
public List<Integer> getOceny() {
return List.of();
}
public double sredniaOcen() {
return 0; // TODO
}
}
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