001 002 import java.io.*; 003 004 /** 005 * Konto version S. 006 * This class is serializable. 007 * Uses synchronized methods to display, add and remove money 008 * from the account. 009 * @author Heinz Kredel. 010 */ 011 public class KontoS implements Konto, Serializable { 012 013 private double stand; 014 015 public KontoS() { stand = 0.0; } 016 017 public KontoS(double a) { stand = a; } 018 019 020 /** 021 * @return stand. 022 */ 023 public synchronized double zeigeGeld() { 024 Work.schaffen(20); 025 return stand; 026 } 027 028 029 /** 030 * @param b amount to put on account. 031 * @return s current account balance. 032 */ 033 public synchronized double putGeld(double b) { 034 double s = stand + b; 035 Work.schaffen(20); 036 stand = s; 037 return s; 038 } 039 040 041 /** 042 * @param b A Double, amount to get from account. 043 * @return s A Double, returns actual balance. 044 */ 045 public synchronized double getGeld(double b) { 046 double s = stand - b; 047 Work.schaffen(20); 048 stand = s; 049 return s; 050 } 051 052 }