some code samples, various examples of simple modeling ideas and some minor algorithms.

DepositAccount.java 626B

12345678910111213141516171819202122232425262728293031
  1. class DepositAccount extends Account
  2. {
  3. private boolean newmonth=true;
  4. private double interest;
  5. public DepositAccount(int sum,double interest)
  6. {
  7. super(sum);
  8. this.interest=interest;
  9. }
  10. //
  11. public void withdraw(int sum) throws AccountException
  12. {
  13. if(sum<=super.balance())
  14. super.withdraw(sum);
  15. else
  16. throw new AccountException("overdraw");
  17. }
  18. public void update()
  19. {
  20. deposit((int)(balance()*interest));
  21. newmonth=true;
  22. }
  23. public void setInterest(double newInterest)
  24. {
  25. interest=newInterest;
  26. }
  27. }