The Problem
Methods that effect a simple state change.
Methods that change the state of structured data.
Version: 5.3.0.10

Lab 7b: Understanding Mutation

Goals: The goals of this lab is to learn how to design methods that change the state of on object or a state of a data structure, as well as how to design tests that verify the effects of such methods.

To understand mutation we need to learn how to:

The Problem

For this lab we will work with bank accounts again. For our purposes we have savings accounts, which must maintain a positive balance, checking accounts, which require a minimum balance (not zero), and credit lines (for borrowing a limited amount of money), which records the balance currently owed and the maximum the customer can borrow.

The bank has a list of Accounts where a customer may deposit or withdraw money. A withdrawal from an account cannot reduce the balance below the minimum, and, for credit lines, cause the balance owed to be above the maximum limit. When a customer deposits money to an account, the balance increases, though for a credit line this decreases the amount owed, which cannot drop below zero.

Methods that effect a simple state change.

Start a new project named Lab7-Bank and import into it the files from Lab7-Bank.zip.

When doing so we encounter a few questions:

Methods that change the state of structured data.

The Bank class keeps track of all accounts.