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
4a674a2a
Commit
4a674a2a
authored
Dec 02, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Klasa Student - początek
parent
88fecb73
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
0 deletions
+46
-0
PrzykladDziedziczenie.java
src/main/java/p10_klasy/v4/PrzykladDziedziczenie.java
+31
-0
Student.java
src/main/java/p10_klasy/v4/Student.java
+15
-0
No files found.
src/main/java/p10_klasy/v4/PrzykladDziedziczenie.java
0 → 100644
View file @
4a674a2a
package
p10_klasy
.
v4
;
public
class
PrzykladDziedziczenie
{
public
static
void
main
(
String
[]
args
)
{
Osoba
osoba
=
new
Osoba
();
// Obiekt klasy Osoba posida tylko te pola i metody, które zostały zdefiniowane w klasie Osoba
osoba
.
imie
=
"Ala"
;
osoba
.
nazwisko
=
"Kowalska"
;
osoba
.
wiek
=
30
;
osoba
.
przedstawSie
();
// Obiekt klasy Student posiada pola i metody pochodzące z klasy Osoba,
// a dodatkowo te pola i metody, które zostały dodefiniownae w klasie Student.
Student
student
=
new
Student
();
student
.
imie
=
"Adam"
;
student
.
nazwisko
=
"Abacki"
;
student
.
wiek
=
21
;
student
.
rok
=
2
;
student
.
kierunek
=
"medycyna"
;
student
.
przedstawSie
();
student
.
dodajOcene
(
4
);
student
.
dodajOcene
(
5
);
System
.
out
.
println
(
"Średnia ocen: "
+
student
.
sredniaOcen
());
Sklep
zabka
=
new
Sklep
(
"Żabka"
,
6
);
zabka
.
sprzedajPiwo
(
student
);
}
}
src/main/java/p10_klasy/v4/Student.java
0 → 100644
View file @
4a674a2a
package
p10_klasy
.
v4
;
public
class
Student
extends
Osoba
{
int
rok
;
String
kierunek
;
void
dodajOcene
(
int
ocena
)
{
// TODO
}
double
sredniaOcen
()
{
return
4.5
;
}
}
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