OOD: Pre conditions – Person

bug report
xkcd
Assignments:
1. Enhance the BetterBankAccount_YI class by adding preconditions
For the constructor: require the amount parameter to be at least zero
For the deposit method: require the amount parameter to be at least zero
For the withdraw method: the amount to be a value between 0 and the current balance

Driver: Write enough code in the tester class to invoke (call) all the methods.
Atm machines.

  1. Write a class Person with the following specifications:

a. Constructor: it takes a name as a string, a second string argument that describes what member of the family it is and, a third string describing the member activity to create a short story. You can make any changes you feel is necessary to accomplish this.

b. Mutator Method: setAge(int anAge). It prompts the user for age and updates the class instance field.

c. Mutator Method: setWhatIamDoing(String doing). It prompts the user and updates the class instance field currentActivity. Keep the number of activities low so it doesn’t become too lengthly.

d. Accessor Method: getWhatIamDoing(). It displays the currentActivity.

Tester class: MyFamilyDriver.java

despicableme2

Create or “instantiate” 4 persons, a mother, a father, a son or a daughter and a friend.
Simulate the following set of events:
The mother keeps milk in the refrigerator.
The father keeps juice in the refrigerator.
The son keeps a can of soda in the refrigerator.
The friend is thirsty and wants to drink something.

This is a story about “encapsulation” so your ending must reflect this concept. Be creative and use your imagination. The lines above is only an example. Do not use it for your own story. You can add more methods and instance fields to the Person ADT so you can make the simulation work nicely.

Some java language help:
String a = “abc”;
String b = “abcdefg”;
System.out.println(b.contains(a)); // true