Skip to content

Commit fc37480

Browse files
committed
proxy
proxy
1 parent fa531a4 commit fc37480

File tree

5 files changed

+29
-2
lines changed

5 files changed

+29
-2
lines changed

MLDesignPatterns-OC/MLDesignPatterns-OC/Proxy/Ticket.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@
1010

1111
@protocol Ticket <NSObject>
1212

13+
- (void)sell;
14+
1315
@end

MLDesignPatterns-OC/MLDesignPatterns-OC/Proxy/TicketOutlets.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
//
88

99
#import <Foundation/Foundation.h>
10+
#import "Ticket.h"
1011

11-
@interface TicketOutlets : NSObject
12+
@interface TicketOutlets : NSObject<Ticket>
1213

1314
@end

MLDesignPatterns-OC/MLDesignPatterns-OC/Proxy/TicketOutlets.m

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,26 @@
77
//
88

99
#import "TicketOutlets.h"
10+
#import "TrainStation.h"
11+
12+
@interface TicketOutlets()
13+
14+
@property (nonatomic, strong) TrainStation *trainStain;
15+
16+
@end
1017

1118
@implementation TicketOutlets
1219

20+
- (instancetype)init {
21+
if (self = [super init]) {
22+
_trainStain = [[TrainStation alloc] init];
23+
}
24+
return self;
25+
}
26+
27+
- (void)sell {
28+
NSLog(@"收取代售手续费5元");
29+
[_trainStain sell];
30+
}
31+
1332
@end

MLDesignPatterns-OC/MLDesignPatterns-OC/Proxy/TrainStation.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
//
88

99
#import <Foundation/Foundation.h>
10+
#import "Ticket.h"
1011

11-
@interface TrainStation : NSObject
12+
@interface TrainStation : NSObject<Ticket>
1213

1314
@end

MLDesignPatterns-OC/MLDesignPatterns-OC/Proxy/TrainStation.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,8 @@
1010

1111
@implementation TrainStation
1212

13+
- (void)sell {
14+
NSLog(@"火车票已经成功卖出");
15+
}
16+
1317
@end

0 commit comments

Comments
 (0)