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
6acf93a7
Commit
6acf93a7
authored
Dec 03, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
referencje - do końca
parent
daac1418
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
154 additions
and
31 deletions
+154
-31
Referencje1.java
src/main/java/p10_klasy/referencje/Referencje1.java
+28
-28
Referencje2.java
src/main/java/p10_klasy/referencje/Referencje2.java
+3
-3
Referencje3.java
src/main/java/p10_klasy/referencje/Referencje3.java
+52
-0
Referencje3_Wersja_Tutor.java
.../p10_klasy/referencje_tutor/Referencje3_Wersja_Tutor.java
+71
-0
No files found.
src/main/java/p10_klasy/referencje/Referencje1.java
View file @
6acf93a7
...
@@ -15,34 +15,34 @@ public class Referencje1 {
...
@@ -15,34 +15,34 @@ public class Referencje1 {
System
.
out
.
println
(
"c: "
+
c
);
System
.
out
.
println
(
"c: "
+
c
);
System
.
out
.
println
();
System
.
out
.
println
();
//
b.wplata(48);
b
.
wplata
(
48
);
//
System.out.println("a: " + a);
System
.
out
.
println
(
"a: "
+
a
);
//
System.out.println("b: " + b);
System
.
out
.
println
(
"b: "
+
b
);
//
System.out.println("c: " + c);
System
.
out
.
println
(
"c: "
+
c
);
//
System.out.println();
System
.
out
.
println
();
//
//
b = a;
b
=
a
;
//
System.out.println("a: " + a);
System
.
out
.
println
(
"a: "
+
a
);
//
System.out.println("b: " + b);
System
.
out
.
println
(
"b: "
+
b
);
//
System.out.println("c: " + c);
System
.
out
.
println
(
"c: "
+
c
);
//
System.out.println();
System
.
out
.
println
();
//
//
c = b;
c
=
b
;
//
System.out.println("a: " + a);
System
.
out
.
println
(
"a: "
+
a
);
//
System.out.println("b: " + b);
System
.
out
.
println
(
"b: "
+
b
);
//
System.out.println("c: " + c);
System
.
out
.
println
(
"c: "
+
c
);
//
System.out.println();
System
.
out
.
println
();
//
//
a = null;
a
=
null
;
//
System.out.println("a: " + a);
System
.
out
.
println
(
"a: "
+
a
);
//
System.out.println("b: " + b);
System
.
out
.
println
(
"b: "
+
b
);
//
System.out.println("c: " + c);
System
.
out
.
println
(
"c: "
+
c
);
//
System.out.println();
System
.
out
.
println
();
//
//
c = b = a;
c
=
b
=
a
;
//
System.out.println("a: " + a);
System
.
out
.
println
(
"a: "
+
a
);
//
System.out.println("b: " + b);
System
.
out
.
println
(
"b: "
+
b
);
//
System.out.println("c: " + c);
System
.
out
.
println
(
"c: "
+
c
);
}
}
}
}
src/main/java/p10_klasy/referencje/Referencje2.java
View file @
6acf93a7
...
@@ -10,15 +10,15 @@ public class Referencje2 {
...
@@ -10,15 +10,15 @@ public class Referencje2 {
System
.
out
.
println
();
System
.
out
.
println
();
// zmiana wartości parametru typu prostego zawsze jest lokalna, nie wpływa na wartości zmiennych w miejscu wywołania (w main)
// zmiana wartości parametru typu prostego zawsze jest lokalna, nie wpływa na wartości zmiennych w miejscu wywołania (w main)
//
x += 55;
x
+=
55
;
// zmiana wewnątrz obiektu jest trwała, może być widoczna z zewnątz (z main, z innej funkcji, z innego wątku, ...)
// zmiana wewnątrz obiektu jest trwała, może być widoczna z zewnątz (z main, z innej funkcji, z innego wątku, ...)
//
b.wplata(48);
b
.
wplata
(
48
);
// przypisanie innego obiektu do parametru typu obiektowego
// przypisanie innego obiektu do parametru typu obiektowego
// (technicznie rzecz biorąc: wpisanie innego adresu)
// (technicznie rzecz biorąc: wpisanie innego adresu)
// nie jest widoczne z zewnątrz
// nie jest widoczne z zewnątrz
//
a = b;
a
=
b
;
System
.
out
.
println
(
"Koniec metody:"
);
System
.
out
.
println
(
"Koniec metody:"
);
System
.
out
.
println
(
"a: "
+
a
);
System
.
out
.
println
(
"a: "
+
a
);
...
...
src/main/java/p10_klasy/referencje/Referencje3.java
0 → 100644
View file @
6acf93a7
package
p10_klasy
.
referencje
;
public
class
Referencje3
{
static
void
metoda
(
Konto
a
,
Konto
b
,
Konto
c
,
int
x
)
{
System
.
out
.
println
(
"Początek metody:"
);
System
.
out
.
println
(
"a: "
+
a
);
System
.
out
.
println
(
"b: "
+
b
);
System
.
out
.
println
(
"c: "
+
c
);
System
.
out
.
println
(
"x: "
+
x
);
System
.
out
.
println
();
x
+=
55
;
b
.
wplata
(
48
);
a
=
new
Konto
(
a
.
numer
,
a
.
saldo
,
a
.
wlasciciel
);
a
.
wplata
(
33
);
a
.
wlasciciel
.
imie
=
"Alicja"
;
System
.
out
.
println
(
"a: "
+
a
);
System
.
out
.
println
(
"b: "
+
b
);
System
.
out
.
println
(
"c: "
+
c
);
System
.
out
.
println
(
"x: "
+
x
);
System
.
out
.
println
();
}
public
static
void
main
(
String
[]
args
)
{
Osoba
ala
=
new
Osoba
(
"Ala"
,
"Kowalska"
,
30
);
Osoba
ola
=
new
Osoba
(
"Ola"
,
"Malinowska"
,
40
);
Konto
a
=
new
Konto
(
1
,
1000
,
ala
);
Konto
b
=
new
Konto
(
2
,
2000
,
ola
);
Konto
c
=
b
;
int
x
=
5000
;
System
.
out
.
println
(
"Początek main:"
);
System
.
out
.
println
(
"a: "
+
a
);
System
.
out
.
println
(
"b: "
+
b
);
System
.
out
.
println
(
"c: "
+
c
);
System
.
out
.
println
(
"x: "
+
x
);
System
.
out
.
println
();
metoda
(
a
,
b
,
c
,
x
);
System
.
out
.
println
(
"Koniec main:"
);
System
.
out
.
println
(
"a: "
+
a
);
System
.
out
.
println
(
"b: "
+
b
);
System
.
out
.
println
(
"c: "
+
c
);
System
.
out
.
println
(
"x: "
+
x
);
}
}
src/main/java/p10_klasy/referencje_tutor/Referencje3_Wersja_Tutor.java
0 → 100644
View file @
6acf93a7
package
p10_klasy
.
referencje_tutor
;
// Od tego miejsca (bez pakietu) skopiujcie to do
// http://pythontutor.com/visualize.html
class
Osoba
{
String
imie
,
nazwisko
;
int
wiek
;
Osoba
()
{
}
Osoba
(
String
imie
,
String
nazwisko
,
int
wiek
)
{
this
.
imie
=
imie
;
this
.
nazwisko
=
nazwisko
;
this
.
wiek
=
wiek
;
}
public
String
toString
()
{
return
imie
+
" "
+
nazwisko
+
" ("
+
wiek
+
" l)"
;
}
}
class
Konto
{
int
numer
;
int
saldo
;
Osoba
wlasciciel
;
public
Konto
(
int
numer
,
int
saldo
,
Osoba
wlasciciel
)
{
this
.
numer
=
numer
;
this
.
saldo
=
saldo
;
this
.
wlasciciel
=
wlasciciel
;
}
@Override
public
String
toString
()
{
return
"Konto nr "
+
numer
+
", "
+
saldo
+
" PLN, wł. "
+
wlasciciel
;
}
void
wplata
(
int
kwota
)
{
saldo
+=
kwota
;
}
}
public
class
Referencje3_Wersja_Tutor
{
static
void
metoda
(
Konto
a
,
Konto
b
,
Konto
c
,
int
x
)
{
x
+=
14
;
b
.
wplata
(
24
);
a
=
new
Konto
(
b
.
numer
,
b
.
saldo
,
b
.
wlasciciel
);
a
.
saldo
+=
77
;
a
.
wlasciciel
.
imie
=
"Alicja"
;
}
public
static
void
main
(
String
[]
args
)
{
Osoba
ala
=
new
Osoba
(
"Ala"
,
"Kowalska"
,
30
);
Osoba
ola
=
new
Osoba
(
"Ola"
,
"Malinowska"
,
25
);
Konto
a
=
new
Konto
(
1
,
1000
,
ala
);
Konto
b
=
new
Konto
(
2
,
2000
,
ola
);
Konto
c
=
b
;
int
x
=
5000
;
metoda
(
a
,
b
,
c
,
x
);
b
=
null
;
a
=
b
;
}
}
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