Amazon.com Widgets Exercise 7 - Why is my implementation section incomplete?
Welcome, Guest. Please login or register.
Did you miss your activation email?
October 20, 2014, 03:47:28 PM
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
|-+ Programming in Objective-C, 4th edition
| |-+ Exercises
| | |-+ Chapter 4
| | | |-+ Exercise 7 - Why is my implementation section incomplete?
Pages: [1] Go Down
Print
Author Topic: Exercise 7 - Why is my implementation section incomplete? (Read 726 times)
Bunchadna
Newbie
*
Posts: 27






on: April 14, 2012, 12:41:03 PM

Here's the first two sections of my program.  I get a warning that my implementation section is incomplete.  I don't understand - little help?

//-----@Interface Section------


@interface Rectangle: NSObject

-(void) print;
-(void) setWidth:   (int)   w;
-(void) setHeight:  (int)   h;
-(int) width;
-(int) height;
-(int) perimeter;
-(int) area;
@end




//--------@Implementation Section---------

@implementation Rectangle
{
    int width;
    int height;
}

-(void) print
{
    NSLog (@"%i X %i", width, height);
}

-(void) setWidth:   (int)   w
{
    width = w;
}

-(void) setHeight:  (int)   h
{
    height = h;
}

-(int) width
{
    return width;
}

-(int) height
{
    return height;
}


@end
Logged
mitchb
Full Member
***
Posts: 143






Reply #1 on: April 14, 2012, 01:34:49 PM

The perimeter and area methods are not defined.

Mitch
Logged

If you give a man a program, you will frustrate him for a day;
If you teach him how to program, you will frustrate him for a lifetime;
     - Anonymous
Bunchadna
Newbie
*
Posts: 27






Reply #2 on: April 14, 2012, 02:16:01 PM

Thank you for replying.  I'm a little confused after reading jgelling's comments in this thread http://classroomm.com/objective-c/index.php?topic=6322.0
Logged
mitchb
Full Member
***
Posts: 143






Reply #3 on: April 15, 2012, 12:41:10 PM

In the referenced thread, notice that in pbb76 example the integer area and perimeter are not used. The answer is found using the methods -area and -perimeter in the NSLog statement [myRectangle area], [myRectangle perimeter]. In the second example by jimmac there is no area or perimeter method, instead he uses the integers area and perimeter to hold the values calculated using the height and width getters, area = [myRect width] * [myRect height]; perimeter = 2 * ([myRect width] + [myRect height]);

Instance methods are declared in the interface section. Instance variables used to be declared in the interface but that changed in Xcode 4.2.

Mitch
Logged

If you give a man a program, you will frustrate him for a day;
If you teach him how to program, you will frustrate him for a lifetime;
     - Anonymous
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.