learningjava/14july2025/Wallet.java

40 lines
1.2 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

public class Wallet {
private String isim;
private Double para;
public Wallet(String isim, String para) {
this.isim = isim;
Double paraDouble = Double.valueOf(para);
if (((paraDouble > -Double.MAX_VALUE) && (paraDouble < Double.MAX_VALUE)) && !paraDouble.isInfinite()) {
this.para = paraDouble;
} else {
System.out.println("O kadar paran var hala buralarda geziyorsun. Kaybol!");
this.para= 1d;
}
}
public String getIsim() {
return this.isim;
}
public Double getPara() {
return this.para;
}
public Boolean paraGuncelleme(Double para) {
if (((this.getPara() > -Double.MAX_VALUE) && (this.getPara() < Double.MAX_VALUE)) && !this.getPara().isInfinite()) {
if ((this.getPara() + para) < 0) {
System.out.println("Yetersiz bakiye. Şu anki bakiye:" + this.getPara());
return false;
} else {
this.para += para;
return true;
}
}
else {
System.out.println("O kadar paran var hala buralarda mı geziyorsun?");
this.para = 1d;
return false;
}
}
}