Commit 192890b6 by Patryk Czarnik

wersja z ifami

parent af3d469a
......@@ -38,8 +38,13 @@ public class Konto {
this.wlasciciel = wlasciciel;
}
public void wplata(int kwota) {
public boolean wplata(int kwota) {
if(kwota > 0) {
this.saldo += kwota;
return true;
} else {
return false;
}
}
public void wyplata(int kwota) {
......
......@@ -30,8 +30,11 @@ public class ProgramBankowy {
System.out.print("Podaj kwotę wpłaty: ");
kwota = sc.nextInt();
sc.nextLine();
konto.wplata(kwota);
if(konto.wplata(kwota)) {
System.out.println("Pieniądze zostały wpłacone");
} else {
System.out.println("Był problem z wpłatą");
}
}
case "Y" -> {
System.out.print("Podaj kwotę wypłaty: ");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment