Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
2
20231104-KursPodstawowyALX
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Patryk Czarnik
20231104-KursPodstawowyALX
Commits
09d90f85
Commit
09d90f85
authored
Dec 02, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Konstruktor i super()
parent
bcfc1387
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
0 deletions
+17
-0
PrzykladDziedziczenie.java
src/main/java/p10_klasy/v4/PrzykladDziedziczenie.java
+8
-0
Student.java
src/main/java/p10_klasy/v4/Student.java
+9
-0
No files found.
src/main/java/p10_klasy/v4/PrzykladDziedziczenie.java
View file @
09d90f85
...
@@ -32,6 +32,14 @@ public class PrzykladDziedziczenie {
...
@@ -32,6 +32,14 @@ public class PrzykladDziedziczenie {
Konto
kontoStudenckie
=
new
Konto
(
1
,
1000
,
student
);
Konto
kontoStudenckie
=
new
Konto
(
1
,
1000
,
student
);
System
.
out
.
println
(
kontoStudenckie
);
System
.
out
.
println
(
kontoStudenckie
);
System
.
out
.
println
();
// Konstruktory NIE SĄ automatycznie dziedziczone z nadklasy do podklasy.
// Student student2 = new Student("Marek", "Markowski", 23);
// Ale w podklasie można zdefiniować konstruktor, który inicjalizuje wszystko, co trzeba, częściowo za pomocą super(...)
Student
student3
=
new
Student
(
"Marek"
,
"Markowski"
,
23
,
3
,
"informatyka"
);
}
}
}
}
src/main/java/p10_klasy/v4/Student.java
View file @
09d90f85
...
@@ -8,6 +8,15 @@ public class Student extends Osoba {
...
@@ -8,6 +8,15 @@ public class Student extends Osoba {
String
kierunek
;
String
kierunek
;
List
<
Integer
>
oceny
=
new
ArrayList
<>();
List
<
Integer
>
oceny
=
new
ArrayList
<>();
Student
()
{
}
Student
(
String
imie
,
String
nazwisko
,
int
wiek
,
int
rok
,
String
kierunek
)
{
super
(
imie
,
nazwisko
,
wiek
);
this
.
rok
=
rok
;
this
.
kierunek
=
kierunek
;
}
void
dodajOcene
(
int
ocena
)
{
void
dodajOcene
(
int
ocena
)
{
oceny
.
add
(
ocena
);
oceny
.
add
(
ocena
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment