RU beehive logo ITEC dept promo banner
ITEC 120
2009spring
ibarland
nokie
jmdymacek

homeinfolectslabsexamshws
textbooktutor/PIsjava.lang docsjava.util docs

lect04b
practice with fields

Review homework

In looking at the incoming homework, it's worth noting:

What's going on

If we haven't already covered it, we'll show:

Adding behaviors to BankAccounts

If the previous material had been previously covered, we'll add an method field to BankAccount:

  1. add a getTotDeposits to our test cases. (What information do we provide when calling the method (inputs), and what information does it return (output)?)
    Note that we hit an interesting question already, before we start writing code: What should the method return for a brand new BankAccount( 50.0 )?
  2. Add a method-stub to our class, so it compiles.
  3. Now, we actually implement this behavior, which requires a few steps.
    1. What additional state does a BankAccount have to keep track of? Add a field.
    2. Initialize that field.
      (Where do we initialize fields, again? And, how many constructors do we have?)
    3. Now fill in our method-stub for getTotDeposits.
      Do we pass our test cases?
    4. Ah, okay — update our existing code, so that our latest field is updated correctly. Now we should pass our test cases!
  4. Let's add another behavior, doMonthlyMaintenance: calling this method causes the total-amount-deposited to be reset to zero.
    (In the future it might also do other things, such as add interest to an account, calculate any penalties, and cause a statement to be printed and mailed.)

homeinfolectslabsexamshws
textbooktutor/PIsjava.lang docsjava.util docs


©2009, Ian Barland, Radford University
Last modified 2009.Feb.13 (Fri)
Please mail any suggestions
(incl. typos, broken links)
to iba�rlandrad�ford.edu
Powered by PLT Scheme