forked from pmougin/F-Script
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathFSAirplane.m
105 lines (85 loc) · 3.38 KB
/
FSAirplane.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/* FSAirplane.m Copyright (c) 1998-2009 Philippe Mougin. */
/* This software is open source. See the license. */
#import "FSAirplane.h"
@implementation FSAirplane
////////////////////////////////// User methods ////////////////////////////////
+ (id) airplaneWithIdent:(id)theIdent model:(id)theModel capacity:(id)theCapacity location:(id)theLocation
{
return [[[self alloc] initWithIdent:theIdent model:theModel capacity:theCapacity location:theLocation] autorelease];
}
- (id) capacity {return capacity;}
- (void) capacity:(id)theCapacity {[theCapacity retain]; [capacity release]; capacity = theCapacity ;}
- (void) setCapacity:(id)theCapacity {[theCapacity retain]; [capacity release]; capacity = theCapacity ;}
- (id) ident {return ident;}
- (void) ident:(id)theIdent {[theIdent retain]; [ident release]; ident = theIdent ;}
- (void) setIdent:(id)theIdent {[theIdent retain]; [ident release]; ident = theIdent ;}
- (id) location {return location;}
- (void) location:(id)theLocation {[theLocation retain]; [location release]; location = theLocation ;}
- (void) setLocation:(id)theLocation {[theLocation retain]; [location release]; location = theLocation ;}
- (id) model {return model;}
- (void) model:(id)theModel {[theModel retain]; [model release]; model = theModel ;}
- (void) setModel:(id)theModel {[theModel retain]; [model release]; model = theModel ;}
////////////////////////////////// Programmer methods ////////////////////////////////
- (id)copyWithZone:(NSZone *)zone
{
return [[[self class] allocWithZone:zone] initWithIdent:ident model:model capacity:capacity location:location];
}
- (void) dealloc
{
[ident release];
[model release];
[capacity release];
[location release];
[super dealloc];
}
- (NSString *)description
{ return [NSString stringWithFormat:@"FSAirplane(ident = %@, model = %@, capacity = %@, location = %@)",ident,model,capacity,location];}
- (void)encodeWithCoder:(NSCoder *)coder
{
if ( [coder allowsKeyedCoding] )
{
[coder encodeObject:ident forKey:@"FSAirplane ident"];
[coder encodeObject:model forKey:@"FSAirplane model"];
[coder encodeObject:capacity forKey:@"FSAirplane capacity"];
[coder encodeObject:location forKey:@"FSAirplane location"];
}
else
{
[coder encodeObject:ident];
[coder encodeObject:model];
[coder encodeObject:capacity];
[coder encodeObject:location];
}
}
- (id)initWithCoder:(NSCoder *)coder
{
self = [super init];
if ( [coder allowsKeyedCoding] )
{
ident = [[coder decodeObjectForKey:@"FSAirplane ident"] retain];
model = [[coder decodeObjectForKey:@"FSAirplane model"] retain];
capacity = [[coder decodeObjectForKey:@"FSAirplane capacity"] retain];
location = [[coder decodeObjectForKey:@"FSAirplane location"] retain];
}
else
{
ident = [[coder decodeObject] retain];
model = [[coder decodeObject] retain];
capacity = [[coder decodeObject] retain];
location = [[coder decodeObject] retain];
}
return self;
}
- (id) initWithIdent:(id)theIdent model:(id)theModel capacity:(id)theCapacity location:(id)theLocation
{
if ((self = [super init]))
{
[self setIdent:theIdent];
[self setModel:theModel];
[self setCapacity:theCapacity];
[self setLocation:theLocation];
return self;
}
return nil;
}
@end