Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Cylinder And Circle
//gcc 5.0.4 #import <Foundation/Foundation.h> @interface MyCircle : NSObject { float radius; } -(void)setRadius:(float)r; -(void)getRadius; -(void)getArea; @end @implementation MyCircle -(void)setRadius:(float)r { radius = r; } -(void)getRadius { NSLog(@"Radius : %f",radius); } -(void)getArea { float area = 3.14*radius*radius; NSLog(@"Area of Circle : %f",area); } @end @interface MyCylinder : MyCircle { float height; } -(void)setHeight:(float)h; -(void)getHeight; -(void)getVolume; @end @implementation MyCylinder -(void)setHeight:(float)h { height = h; } -(void)getHeight { NSLog(@"height : %f",height); } -(void)getVolume { float volume = 3.14*radius*radius*height; NSLog(@"Volume of Cylinder : %f",volume); } @end int main (int argc, const char * argv[]) { MyCylinder *c1 = [[MyCylinder alloc] init]; [c1 setRadius:2]; [c1 setHeight:2]; [c1 getRadius]; [c1 getHeight]; [c1 getArea]; [c1 getVolume]; return 0; }
run
|
edit
|
history
|
help
0
linear hybrid cellular automaton reversible random bit generator
NSString Examples in one
NSSet(Create,Enumrate,Compare,Checking,Combine)
Ex Srting Methods
find maximum in objective c
primitive datatypes objective c
NSMutable Exercise
NSString Examples in one
Func Var and Ops ObjC
Author1