I just started to learn Objective C with Programming in Objective C by Stephen G. Kochanand and I would love to get your feedback to see if I'm getting OOP concept with Objective-C right.GraphicObject.h#import <Foundation/Foundation.h>@interface GraphicObject : NSObject{    int fillColor;    int lineColor;    BOOL filled;}-(void) fillColor: (int) fc;-(void) lineColor: (int) lc;-(int) getFilledColor;-(int) getLineColor;-(BOOL) filled;@endGraphicObject.m#import GraphicObject.h@implementation GraphicObject//--------------------------Get and Set filled/line colors----------------------------------// -(void) fillColor:(int)fc{    fillColor = fc;}-(void) lineColor:(int)lc{    lineColor = lc;}-(int) getFilledColor{    return fillColor;}-(int) getLineColor{    return lineColor;}//-------------------------------------Is filled?--------------------------------------------//-(BOOL) filled{    filled = fillColor;    return filled;}@endRectangle.h#import GraphicObject.h#import XYPoint.h@interface Rectangle : GraphicObject@property float width, height, tx, ty;-(XYPoint *) origin;-(void) setWidth: (float) w andHeight: (float) h;-(void) setOrigin:(XYPoint *)pt;-(void) translate:(XYPoint *)point;-(float) area;-(float) perimeter;@endRectangle.m#import Rectangle.h#import XYPoint.h@implementation Rectangle{    XYPoint *origin;}@synthesize width, height, tx, ty;-(void) setWidth: (float) w andHeight: (float) h{    width = w;    height = h;}-(void) translate:(XYPoint *)point{    tx = origin.x + point.x;    ty = origin.y + point.y;}-(void)setOrigin:(XYPoint *)pt{    if (!origin)        origin = [[XYPoint alloc] init];    origin.x = pt.x;    origin.y = pt.y;}-(XYPoint *) origin{    return origin;}-(float) area{    return width * height;}-(float) perimeter{    return (width + height) * 2;}@endXYPoint.h#import <Foundation/Foundation.h>@interface XYPoint : NSObject@property float x, y;-(void) setX:(float)xP andY: (float)yP;@endXYPoint.m#import XYPoint.h@implementation XYPoint@synthesize x, y;-(void) setX:(float)xP andY:(float)yP{    x = xP;    y = yP;}@endCircle.h#import GraphicObject.h@interface Circle : GraphicObject@property float radius, diameter;-(float) getArea;-(float) getCircumference;-(void) setDiameter:(float)d andRadius: (float)r;@endCircle.m#import Circle.h@implementation Circle@synthesize radius, diameter;-(float) getArea{    return (radius * radius) * 3.14;}-(float) getCircumference{    return (3.14 * diameter);}-(void) setDiameter:(float)d andRadius: (float)r;{    diameter = d;    radius = r;}@endTriangle.h#import GraphicObject.h@interface Triangle : GraphicObject@property float sideA, sideB, sideC, base, height;-(float) getArea;-(float) getPerimeter;-(void) setBase:(float)b andHeight:(float)h;-(void) setSideA:(float)a andB: (float)b andC: (float)c;@endTriangle.m#import Triangle.h@implementation Triangle@synthesize sideA, sideB, sideC, base, height;-(float) getArea{    return (base/2) * height;}-(float) getPerimeter{    return sideA + sideB + sideC;}-(void) setBase:(float)b andHeight:(float)h;{    base = b;    height = h;}-(void) setSideA:(float)a andB: (float)b andC: (float)c{    sideA = a;    sideB = b;    sideC = c;}@endmain#import <Foundation/Foundation.h>#import Rectangle.h#import Circle.h#import Triangle.h#import GraphicObject.h#import XYPoint.hint main(int argc, const char * argv[]){    @autoreleasepool {//----------------------------------Creating instance objects of all classes-------------------------------        Rectangle *myRectangle = [[Rectangle alloc] init];        Circle *myCircle = [[Circle alloc] init];        Triangle *myTriangle = [[Triangle alloc] init];        XYPoint *myPoint = [[XYPoint alloc] init];//----------------------------------Testing XYPoint class and Rectangle class-------------------------------        [myPoint setX:5 andY:10];        [myRectangle setOrigin:myPoint];        [myRectangle setWidth:10 andHeight:7];        NSLog(@Rectangle Width = %.1f Height = %.1f is at (%.1f,%.1f), myRectangle.width, myRectangle.height, myRectangle.origin.x, myRectangle.origin.y);//------------------------------------------Testing Circle class--------------------------------------------        [myCircle setDiameter:6 andRadius:3];        NSLog(@Circle area = %.1f Circumference = %.1f, [myCircle getArea], [myCircle getCircumference]);//-----------------------------------------Testing Triangle class-------------------------------------------        [myTriangle setSideA:5 andB:6 andC:7];        [myTriangle setBase:5 andHeight:12];        NSLog(@Triangle Perimeter = %.1f Area = %.1f, [myTriangle getPerimeter], [myTriangle getArea]);    }    return 0;}
Creating shapes program with multiple classes (different files)
beginner;objective c;computational geometry
I have to make the same suggestion as for your last question: use properties and stick to name conventionsYour code as it is#import <Foundation/Foundation.h>@interface GraphicObject : NSObject{    int fillColor;    int lineColor;    BOOL filled;}-(void) fillColor: (int) fc;-(void) lineColor: (int) lc;-(int) getFilledColor;-(int) getLineColor;-(BOOL) filled;@endYour code with name conventions (setters of an ivar prefixed with set, getters named as the ivar/property)#import <Foundation/Foundation.h>@interface GraphicObject : NSObject{    int fillColor;    int lineColor;    BOOL filled;}-(void) setFillColor: (int) fc;-(void) setLineColor: (int) lc;-(int) filledColor;-(int) lineColor;-(BOOL) filled;@endYour code with properties#import <Foundation/Foundation.h>@interface GraphicObject : NSObject{    int fillColor;    int lineColor;    BOOL filled;}@property int fillColor;@property int lineColor;@property BOOL filled;@endBut actually for nowadays compilers you don't need to declare iVars for properties#import <Foundation/Foundation.h>@interface GraphicObject : NSObject@property int fillColor;@property int lineColor;@property BOOL filled;@endand you also dont need to declare synthesize, as it is default nowAs properties generate setters7getters for you, the implementation could be#import GraphicObject.h@implementation GraphicObject@endCocoa's name conventions suggest not to use the word and in method names to indicate the setting of an object's state-(void) setDiameter:(float)d andRadius: (float)r;becomes -(void) setDiameter:(float)d radius: (float)r;BTW: diamater = radius * 2, so there is no need to pass bothand is suggested for action that might be triggered after setting.Some made up example -(void) sendData:(NSData *)data            toURL:(NSURL *) url andPerformSuccessSelector:(SEL)successSelector    performFailureSelector:(SEL)failureSelector;-(void) setSideA:(float)a b: (float)b c: (float)cinstead of XYPoint class#import XYPoint.h@implementation XYPoint@synthesize x, y;-(void) setX:(float)xP andY:(float)yP{    x = xP;    y = yP;}@endyou could use the CGPoint struct (iOS) or NSPoint (Cocoa)struct CGPoint {   CGFloat x;   CGFloat y;};typedef struct CGPoint CGPoint;As this is a plain C type, you cant use it, where you need to use objects. Wrap it in a NSValue object than, for example to store it into an array:NSArray *points = @[[NSValue valueWithCGPoint:p1], [NSValue valueWithCGPoint:p2]]I just had a look into Stephen G. Kochan's book in amazon. he is also sticking to the naming conventions, see page 96 program 6.2. -setNumerator: as setter, -numerator as getter.Although he is not using properties in this example, he most likely will also explain and use them later in the book.