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
eaa09d07
Commit
eaa09d07
authored
Apr 12, 2024
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Konto - naprawienie dziwnych sytuacji
parent
5986e657
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
3 deletions
+11
-3
Konto.java
src/p11_klasy/enkapsulacja/Konto.java
+11
-3
No files found.
src/p11_klasy/enkapsulacja/Konto.java
View file @
eaa09d07
...
...
@@ -6,9 +6,12 @@ public class Konto {
private
Osoba
wlasciciel
;
public
Konto
(
int
numer
,
int
saldo
,
Osoba
wlasciciel
)
{
if
(
saldo
<
0
)
{
throw
new
IllegalArgumentException
(
"ujemne saldo"
);
}
this
.
numer
=
numer
;
this
.
saldo
=
saldo
;
this
.
wlasciciel
=
wlasciciel
;
setWlasciciel
(
wlasciciel
)
;
}
@Override
...
...
@@ -35,6 +38,9 @@ public class Konto {
}
public
void
setWlasciciel
(
Osoba
wlasciciel
)
{
if
(
wlasciciel
==
null
)
{
throw
new
IllegalArgumentException
(
"właśniciel null"
);
}
this
.
wlasciciel
=
wlasciciel
;
}
...
...
@@ -42,7 +48,8 @@ public class Konto {
if
(
kwota
<=
0
)
{
throw
new
IllegalArgumentException
(
"ujemna kwota wpłaty"
);
}
this
.
saldo
+=
kwota
;
// this.saldo += kwota;
this
.
saldo
=
Math
.
addExact
(
this
.
saldo
,
kwota
);
}
public
void
wyplata
(
int
kwota
)
throws
BrakSrodkow
{
...
...
@@ -52,6 +59,7 @@ public class Konto {
if
(
kwota
>
saldo
)
{
throw
new
BrakSrodkow
(
"za mało kasy"
);
}
this
.
saldo
-=
kwota
;
// this.saldo -= kwota;
this
.
saldo
=
Math
.
subtractExact
(
this
.
saldo
,
kwota
);
}
}
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