Commit 37c47d02 by Patryk Czarnik

System.err

parent 192890b6
...@@ -38,12 +38,11 @@ public class Konto { ...@@ -38,12 +38,11 @@ public class Konto {
this.wlasciciel = wlasciciel; this.wlasciciel = wlasciciel;
} }
public boolean wplata(int kwota) { public void wplata(int kwota) {
if(kwota > 0) { if(kwota > 0) {
this.saldo += kwota; this.saldo += kwota;
return true;
} else { } else {
return false; System.err.println("ujemna kwota wpłaty");
} }
} }
......
...@@ -30,11 +30,8 @@ public class ProgramBankowy { ...@@ -30,11 +30,8 @@ public class ProgramBankowy {
System.out.print("Podaj kwotę wpłaty: "); System.out.print("Podaj kwotę wpłaty: ");
kwota = sc.nextInt(); kwota = sc.nextInt();
sc.nextLine(); sc.nextLine();
if(konto.wplata(kwota)) { konto.wplata(kwota);
System.out.println("Pieniądze zostały wpłacone"); System.out.println("Pieniądze zostały wpłacone");
} else {
System.out.println("Był problem z wpłatą");
}
} }
case "Y" -> { case "Y" -> {
System.out.print("Podaj kwotę wypłaty: "); 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