1
Can these messages be sent to a String object and explain why or why not?
a.
copyFrom:to:
b.
copyReplaceAll:with:
2.
Add a method with the selector containsPassword in the String class. This
method should return true if the receiver contains the characters p, a, s, s,
w, o, r, d in that order with possibly other characters between them. It does
not matter if the characters are upper or lower case. Hint look at the match:
method in CharacterArray. The following should return true:
3.
Define a quadrant method in the Point class. If x & y are both greater than
zero the method returns 1. If y is greater than zero but x is less zero the
methods return 2. If both x & y are less than zero return 3. If x is
greater than zero but y is less than zero return 4. If both x & y are zero
return 0. Otherwise if the point is on x-axis return 2.5 and if it is on the
y-axis return 1.5.
4.
Create a BankAccount class. The class needs to maintain a balance. Banks do not
like round-off errors so no rounding-off is allowed. Assume we are using US
currency so someone may wish to deposit 123.21. We need the following methods:
deposit:
anAmount
Adds
the amount to the current balance
withdrawl:
anAmount
Subtracts
the amount from the current balance as long as the resulting balance is not
negative.
balance Answer
the current balance
For
problems 2, 3 & 4 you are to turn in your source code.