Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jvstd1
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
jvstd1
Commits
79e29206
Commit
79e29206
authored
Sep 30, 2024
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Konto - wersja z bool
parent
cd360f46
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
4 deletions
+13
-4
Konto.java
src/main/java/p06_enkapsulacja/Konto.java
+8
-2
ProgramBankowy.java
src/main/java/p06_enkapsulacja/ProgramBankowy.java
+5
-2
No files found.
src/main/java/p06_enkapsulacja/Konto.java
View file @
79e29206
...
...
@@ -35,8 +35,14 @@ public class Konto {
return
saldo
;
}
public
void
wplata
(
int
kwota
)
{
saldo
+=
kwota
;
public
boolean
wplata
(
int
kwota
)
{
if
(
kwota
>
0
)
{
saldo
+=
kwota
;
return
true
;
}
else
{
System
.
err
.
println
(
"Kwota wpłaty nie jest dodatnia"
);
return
false
;
}
}
public
void
wyplata
(
int
kwota
)
{
...
...
src/main/java/p06_enkapsulacja/ProgramBankowy.java
View file @
79e29206
...
...
@@ -30,8 +30,11 @@ public class ProgramBankowy {
System
.
out
.
print
(
"Podaj kwotę wpłaty: "
);
kwota
=
sc
.
nextInt
();
sc
.
nextLine
();
konto
.
wplata
(
kwota
);
System
.
out
.
println
(
"Pieniądze zostały wpłacone"
);
if
(
konto
.
wplata
(
kwota
))
{
System
.
out
.
println
(
"Pieniądze zostały wpłacone"
);
}
else
{
System
.
out
.
println
(
"nie ma wpłaty"
);
}
}
case
"Y"
->
{
System
.
out
.
print
(
"Podaj kwotę wypłaty: "
);
...
...
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