Commit | Line | Data |
66b226e5 |
1 | # Your tasks ... |
2 | # |
f867e81a |
3 | # First, you must make the account associated with a Person a proper |
4 | # class of its own. Call it BankAccount. |
66b226e5 |
5 | # |
6 | # This class should have two attributes, "balance", an Int that |
7 | # defaults to 100, and "owner", a Person object. |
8 | # |
9 | # The owner attribute should be a weak reference to prevent cycles. |
10 | # |
11 | # Copy the deposit and withdraw methods from the HasAccount role. |
12 | # |
ed84c5c6 |
13 | # Finally, add a read-only history attribute. This will be an ArrayRef of |
54289814 |
14 | # Int's. This should default to an empty array reference. Use a Native |
15 | # delegation method to push values onto this attribute. |
66b226e5 |
16 | # |
648519ab |
17 | # Use a trigger to record the _old value_ of the balance each time it |
ed84c5c6 |
18 | # changes. This means your trigger should not do anything if it is not passed |
f867e81a |
19 | # an old value (this will be the case when the attribute is set for the first |
ed84c5c6 |
20 | # time). |
66b226e5 |
21 | # |
f867e81a |
22 | # Now you can delete the HasAccount role entirely. Instead, add an "account" |
23 | # attribute to Person directly. |
66b226e5 |
24 | # |
f867e81a |
25 | # This new account attribute should default to a new BankAccount object. Use |
26 | # delegation so that when the code calls Person->deposit and Person->withdraw, |
27 | # it calls those methods on the person's BankAccount object. |
66b226e5 |
28 | # |
29 | # Add a BUILD method to the Person class to set the owner of the |
30 | # Person's bank account to $self. |
31 | |
32 | use strict; |
33 | use warnings; |
34 | |
35 | use lib 't/lib'; |
36 | |
37 | use MooseClass::Tests; |
38 | |
66b226e5 |
39 | MooseClass::Tests::tests06(); |