Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
kurs_java_alx_20240321
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
kurs_java_alx_20240321
Commits
43a72ddb
Commit
43a72ddb
authored
Apr 11, 2024
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jakieś poprawki w polimorfizmach
parent
b742211d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
1 deletions
+5
-1
Polimorfizm1.java
src/p11_klasy/podstawy/Polimorfizm1.java
+1
-1
Student.java
src/p11_klasy/podstawy/Student.java
+4
-0
No files found.
src/p11_klasy/podstawy/Polimorfizm1.java
View file @
43a72ddb
...
...
@@ -48,6 +48,7 @@ public class Polimorfizm1 {
System
.
out
.
println
(
ktos
.
getClass
());
// Aby sprawdzić, czy rzutowanie będzie możliwe, używamy instanceof:
// Gdyby w zmiennej ktos był obiekt klasy StudentInformatyki, to też wyszłoby true
if
(
ktos
instanceof
Student
)
{
// rzutowanie jest bezpieczne
System
.
out
.
println
(
((
Student
)
ktos
).
rok
);
...
...
@@ -70,7 +71,6 @@ public class Polimorfizm1 {
System
.
out
.
println
(
student
.
oceny
);
System
.
out
.
println
(
student
.
sredniaOcen
());
System
.
out
.
println
(((
Student
)
ktos
).
sredniaOcen
());
}
}
src/p11_klasy/podstawy/Student.java
View file @
43a72ddb
...
...
@@ -8,6 +8,10 @@ public class Student extends Osoba {
int
rok
;
List
<
Integer
>
oceny
=
new
ArrayList
<>();
{
System
.
out
.
println
(
"init Student"
);
}
static
{
System
.
out
.
println
(
"static Student"
);
}
public
Student
()
{
}
...
...
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