hi i am new to objective C . i am writing a program where the data's are given , in the output it should display name , id no and enter and exit time and total time spend in office.
i want the time format to show in hour:min format for ex 10:00 idk how to put it , any help would be great
Code:
#import <Foundation/Foundation.h>
@interface employee : NSObject
{
NSString *name;
int idno;
int entertime;
int exittime;
}
-(void) print;
-(void) setName : (NSString*) nn;
-(void) setId : (int) iden;
-(void) setentertime : (int) enter;
-(void) setexittime : (int) exit;
-(void) totaltime;
@end
@implementation employee
-(void) print
{
NSLog(@"The name = %@",name);
NSLog(@"The id number of the employee = %i",idno);
NSLog(@"The entertime of the employee = %i",entertime);
NSLog(@"The exittime of the employee = %i",exittime);
}
-(void) setName : (NSString*) nn;
{
name=nn;
}
-(void) setId : (int) iden;
{
idno=iden;
}
-(void) setentertime : (int) enter;
{
entertime = enter;
}
-(void) setexittime : (int) exit;
{
exittime=exit;
}
-(void) totaltime
{
int totaltime;
totaltime=exittime-entertime;
NSLog(@"Employee worked for %2i hours",totaltime);
}
@end
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
employee *myemployee;
myemployee=[[employee alloc]init];
[myemployee setName:@"rahul"];
[myemployee setId:23];
[myemployee setexittime:17];
[myemployee setentertime:10];
[myemployee print];
[myemployee totaltime];
[pool drain];
return 0;
}