شروع oop Objective C Programming

محلی برای نرم افزارهای سایت ساز و مباحث مربوط به برنامه‌نویسی چون Objective-C ،Cocoa و غیره
ارسال پست
p
pouyan_objc
پست: 26
تاریخ عضویت: 25 آپریل 2010, 20:16
محل اقامت: Tehran
تماس:

شروع oop Objective C Programming

پست توسط pouyan_objc »

امید وارم در ‍‍‍‍پیشرفت کرده باشید
this is our first O,really Object Oriented Programming(oop program :
hope to enjoy
!) 

کد: انتخاب همه

#import <Foundation/Foundation.h>

// Interface Section Starts Here

@interface BankAccount: NSObject
{
        double accountBalance;
        long accountNumber;
}
-(void) setAccount: (long) y andBalance: (double) x;
-(double) getAccountBalance;
-(long) getAccountNumber;
-(void) setAccountBalance: (double) x;
-(void) setAccountNumber: (long) y;
-(void) displayAccountInfo;
@end


// Implementation Section Starts Here

@implementation BankAccount

-(void) setAccount: (long) y andBalance: (double) x;
{
        accountBalance = x;
        accountNumber = y;
}

-(void) setAccountBalance: (double) x
{
        accountBalance = x;
}

-(double) getAccountBalance
{
        return accountBalance;
}

-(void) setAccountNumber: (long) y
{
        accountNumber = y;
}

-(long) getAccountNumber
{
        return accountNumber;
}


-(void) displayAccountInfo
{
        NSLog (@"Account Number %i has a balance of %f", accountNumber, accountBalance);
}
@end

// Program Section Starts Here

int main (int argc, const char * argv[])
{
        NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

        BankAccount *account1;

        account1 = [BankAccount alloc];

        account1 = [account1 init];

        [account1 setAccountBalance: 1500.53];
        [account1 setAccountNumber: 34543212];

        [account1 displayAccountInfo];

        [account1 setAccount: 4543455 andBalance: 3010.10];

        NSLog(@"Number = %i, Balance = %f", [account1 getAccountNumber], [account1 getAccountBalance]);

        [pool drain];

        return 0;


}
description :
Declaring an Objective-C Class Interface

کد: انتخاب همه

@interface NewClassName: ParentClass {
ClassMembers;
}

ClassMethods;
@end
Declaring an Objective-C Class Implementation

کد: انتخاب همه

@implementation NewClassName
ClassMethods
@end
any problem mail me at :
kalakbarghi@gmail.com
kalakbarghi@gmail.com
MacBook Pro MB/LA991
iPod touch 8 GIG
ارسال پست

چه کسی حاضر است؟

کاربران حاضر در این انجمن: کاربر جدیدی وجود ندارد. و 0 مهمان