Create a new category called HW#2 and place the new object class
called Triple in that category. The Triple class should have base class
Point. Add the instance variable z to your new class and methods z and
z: . Also add instance
method "setX: setY: setZ:" and class method "x: y: z:". You will
need to implement printOn: and storeOn: in the
class so the object can display itself properly. Implement
a way so that Points can be converted to Triples via the @ method but
Triples should then undefine the @ method. Implement
the methods for operator + and -. + and - needs to work for Triple +
Triple, Triple + Point, and Triple + Number. DO NOT implement the
other direction (i.e. Number + Triple) since this is the deadly
problem I mentioned in class. Do min:, max:, and rounded so they
perform similar tasks that you can SEE in the Point class. Add the
conversions asTriple so it is understood by the Number class, Point
class, and Triple
class. Add asPoint to the Triple class isnce this will help in your
implementation (hint + and -). Note: reuse code of the parent classes. Bonus if you can
write a storeOn: method that can be filed in and generate an
object.
Just to list all the methods to add:
Number class - asTriple
Point class - @, asTriple
Triple class - class method x: y: z:, setX: setY: setZ:, printOn:,
storeOn:, z, z:, min:, max:, rounded, @, asPoint, asTriple, +, -
One final important note. You can see how inheritance works since
printOn:, min:, @, and other methods will work even if you don't do
them in the Triple class but they don't return the desired result.
Bonus: