Guest User

Untitled

a guest
Jun 17th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1.  
  2.  
  3. // Girokonto
  4. public class Giro {
  5. double konto; // Kontostand
  6. double gutzins; // Guthabenzins mit 1%
  7. double ueberzins; // Überzugszins mit 10%
  8.  
  9. Giro(double konto){
  10. this.konto = konto;
  11. this.gutzins = 0.01;
  12. this.ueberzins = 0.1;
  13.  
  14.  
  15. }
  16.  
  17. // Berechnet den Guthabens- bzw. Überzugszinsbetrag für den aktuellen Kontostand
  18. public double calculateInterest(){
  19.  
  20. if (0 >= this.konto)
  21. return (this.konto * gutzins);
  22.  
  23. else
  24. return (this.konto * ueberzins);
  25.  
  26. }
  27.  
  28. // Ermöglicht Geld auf ein Konto einzuzahlen
  29. public Giro deposit(double betrag){
  30. return new Giro(this.konto + betrag);
  31.  
  32. }
  33.  
  34. // Berechnet Guthabens bzw. Überzugszinsen und rechnet diese auf den aktuellen Kontostand an
  35. public Giro accountWithInterest(){
  36. return new Giro(this.konto + this.konto.calculateInterest());
  37. }
  38. }
Add Comment
Please, Sign In to add comment