Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
emp class
#import <Foundation/Foundation.h> @interface Student:NSObject { NSString *name; NSString *gender; NSString *joindate; NSString *bdate; NSString *city; NSString *dp; int age; int salary; } -(int) salary; -(int) age; - (NSString*) name; - (NSString*) gender; - (NSString*) joindate; - (NSString*) bdate; - (NSString*) city; - (NSString*) dp; - (void)setsalary:(int)slry; - (void)setName:(NSString*)sname; @end @implementation Student -(id)init { self = [super init]; salary = 1000; name = @"Parth Ganatra"; gender=@"Male"; joindate=@"3/3/2015"; bdate=@"17/5/1997"; city=@"Rajkot"; dp=@"Computer"; age = 19; return self; } - (void)setsalary:(int)slry { salary = slry; } - (void)setName:(NSString*)sname { name = sname; } -(int) salary { return salary; } -(NSString*) name { return name; } -(NSString*) gender { return gender; } -(NSString*) joindate { return joindate; } -(NSString*) bdate { return bdate; } -(NSString*) city { return city; } -(NSString*) dp { return dp; } -(int) getage { return age; } @end int main( ) { Student *s1 = [[Student alloc]init]; // Create student object int salary,age; NSString *name; NSString *gender; NSString *joindate; NSString *bdate; NSString *city; NSString *dp; salary = [s1 salary]; name = [s1 name]; gender=[s1 gender]; joindate=[s1 joindate]; bdate=[s1 bdate]; city=[s1 city]; dp=[s1 dp]; age = [s1 getage]; NSLog(@"Student Name : %@", name); NSLog(@"Student gender : %@", gender); NSLog(@"Student joindate : %@", joindate); NSLog(@"Student bdate : %@", bdate); NSLog(@"Student city : %@", city); NSLog(@"Student dipartment : %@", dp); NSLog(@"Student Age : %d", age); NSLog(@"Student salary : %d", salary); [s1 setsalary:13000]; salary = [s1 salary]; [s1 setName:@"PArth Ganatra"]; name = [s1 name]; NSLog(@"Student set Name : %@", name); NSLog(@"Student set salry : %d", salary); return 0; }
run
|
edit
|
history
|
help
1
primitive datatypes objective c
NSMutableStringProgram
geomatric operations in objective c
geomatric operations in objective c
NSNumber
asss
simple inheritance in objective c
Ex of String methods
string mutable
Obj-C_Program_Structure_1