Amazon.com Widgets Different approach to 4.10
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 18, 2013, 10:48:08 AM
Home Help Search chat Login Register   
News: Read this please.The Great Kangaroo Escape Looking for reviews of the 4th ed on Amazon!   Twitter:  @skochan
                     

+  Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
|-+  Old Stuff
| |-+  Answers to Exercises
| | |-+  Chapter 4
| | | |-+  Different approach to 4.10
Pages: [1]   Go Down
Print
Author Topic: Different approach to 4.10  (Read 426 times)
tomtso
Newbie
*
Posts: 3


Email




« on: December 14, 2011, 01:34:04 PM »

I did it differently.
 Instead of writing new methods , I made a memory instance (object), and reused the methods

Calculator *memory=[Calculator new];


   [memory setAccumulator: 100.0];                           //memoryStore
   NSLog(@"memory is %g",[memory accumulator]);   //memoryRecall 
   NSLog(@"memory is %g",[memory add:200]);         //memoryAdd
   NSLog(@"memory is %g",[memory subtract:10]);     //memorySubtract
   NSLog(@"memory is %g",[memory clear]);               //memoryClear

Is this lazy and not doing the excercise correctly?

At least it saved me a lot of line reproduction.
Logged
Pages: [1]   Go Up
Print
Jump to:  



Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents (c) 2009 classroomM.com. All rights reserved.