Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Girokonto
- public class Giro {
- double konto; // Kontostand
- double gutzins; // Guthabenzins mit 1%
- double ueberzins; // Überzugszins mit 10%
- Giro(double konto){
- this.konto = konto;
- this.gutzins = 0.01;
- this.ueberzins = 0.1;
- }
- // Berechnet den Guthabens- bzw. Überzugszinsbetrag für den aktuellen Kontostand
- public double calculateInterest(){
- if (0 >= this.konto)
- return (this.konto * gutzins);
- else
- return (this.konto * ueberzins);
- }
- // Ermöglicht Geld auf ein Konto einzuzahlen
- public Giro deposit(double betrag){
- return new Giro(this.konto + betrag);
- }
- // Berechnet Guthabens bzw. Überzugszinsen und rechnet diese auf den aktuellen Kontostand an
- public Giro accountWithInterest(){
- return new Giro(this.konto + this.konto.calculateInterest());
- }
- }
Add Comment
Please, Sign In to add comment