Skip to content

Commit d351ff9

Browse files
committed
exercise10
1 parent 22bd820 commit d351ff9

File tree

10 files changed

+389
-0
lines changed

10 files changed

+389
-0
lines changed
Lines changed: 244 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,244 @@
1+
// !$*UTF8*$!
2+
{
3+
archiveVersion = 1;
4+
classes = {
5+
};
6+
objectVersion = 46;
7+
objects = {
8+
9+
/* Begin PBXBuildFile section */
10+
B4EDACF21C147BA1000AC60D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = B4EDACF11C147BA1000AC60D /* main.m */; };
11+
/* End PBXBuildFile section */
12+
13+
/* Begin PBXCopyFilesBuildPhase section */
14+
B4EDACEC1C147BA1000AC60D /* CopyFiles */ = {
15+
isa = PBXCopyFilesBuildPhase;
16+
buildActionMask = 2147483647;
17+
dstPath = /usr/share/man/man1/;
18+
dstSubfolderSpec = 0;
19+
files = (
20+
);
21+
runOnlyForDeploymentPostprocessing = 1;
22+
};
23+
/* End PBXCopyFilesBuildPhase section */
24+
25+
/* Begin PBXFileReference section */
26+
B4EDACEE1C147BA1000AC60D /* Chap10_exercise */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = Chap10_exercise; sourceTree = BUILT_PRODUCTS_DIR; };
27+
B4EDACF11C147BA1000AC60D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
28+
/* End PBXFileReference section */
29+
30+
/* Begin PBXFrameworksBuildPhase section */
31+
B4EDACEB1C147BA1000AC60D /* Frameworks */ = {
32+
isa = PBXFrameworksBuildPhase;
33+
buildActionMask = 2147483647;
34+
files = (
35+
);
36+
runOnlyForDeploymentPostprocessing = 0;
37+
};
38+
/* End PBXFrameworksBuildPhase section */
39+
40+
/* Begin PBXGroup section */
41+
B4EDACE51C147BA1000AC60D = {
42+
isa = PBXGroup;
43+
children = (
44+
B4EDACF01C147BA1000AC60D /* Chap10_exercise */,
45+
B4EDACEF1C147BA1000AC60D /* Products */,
46+
);
47+
sourceTree = "<group>";
48+
};
49+
B4EDACEF1C147BA1000AC60D /* Products */ = {
50+
isa = PBXGroup;
51+
children = (
52+
B4EDACEE1C147BA1000AC60D /* Chap10_exercise */,
53+
);
54+
name = Products;
55+
sourceTree = "<group>";
56+
};
57+
B4EDACF01C147BA1000AC60D /* Chap10_exercise */ = {
58+
isa = PBXGroup;
59+
children = (
60+
B4EDACF11C147BA1000AC60D /* main.m */,
61+
);
62+
path = Chap10_exercise;
63+
sourceTree = "<group>";
64+
};
65+
/* End PBXGroup section */
66+
67+
/* Begin PBXNativeTarget section */
68+
B4EDACED1C147BA1000AC60D /* Chap10_exercise */ = {
69+
isa = PBXNativeTarget;
70+
buildConfigurationList = B4EDACF51C147BA1000AC60D /* Build configuration list for PBXNativeTarget "Chap10_exercise" */;
71+
buildPhases = (
72+
B4EDACEA1C147BA1000AC60D /* Sources */,
73+
B4EDACEB1C147BA1000AC60D /* Frameworks */,
74+
B4EDACEC1C147BA1000AC60D /* CopyFiles */,
75+
);
76+
buildRules = (
77+
);
78+
dependencies = (
79+
);
80+
name = Chap10_exercise;
81+
productName = Chap10_exercise;
82+
productReference = B4EDACEE1C147BA1000AC60D /* Chap10_exercise */;
83+
productType = "com.apple.product-type.tool";
84+
};
85+
/* End PBXNativeTarget section */
86+
87+
/* Begin PBXProject section */
88+
B4EDACE61C147BA1000AC60D /* Project object */ = {
89+
isa = PBXProject;
90+
attributes = {
91+
LastUpgradeCheck = 0710;
92+
ORGANIZATIONNAME = "Yingbo Liu";
93+
TargetAttributes = {
94+
B4EDACED1C147BA1000AC60D = {
95+
CreatedOnToolsVersion = 7.1.1;
96+
};
97+
};
98+
};
99+
buildConfigurationList = B4EDACE91C147BA1000AC60D /* Build configuration list for PBXProject "Chap10_exercise" */;
100+
compatibilityVersion = "Xcode 3.2";
101+
developmentRegion = English;
102+
hasScannedForEncodings = 0;
103+
knownRegions = (
104+
en,
105+
);
106+
mainGroup = B4EDACE51C147BA1000AC60D;
107+
productRefGroup = B4EDACEF1C147BA1000AC60D /* Products */;
108+
projectDirPath = "";
109+
projectRoot = "";
110+
targets = (
111+
B4EDACED1C147BA1000AC60D /* Chap10_exercise */,
112+
);
113+
};
114+
/* End PBXProject section */
115+
116+
/* Begin PBXSourcesBuildPhase section */
117+
B4EDACEA1C147BA1000AC60D /* Sources */ = {
118+
isa = PBXSourcesBuildPhase;
119+
buildActionMask = 2147483647;
120+
files = (
121+
B4EDACF21C147BA1000AC60D /* main.m in Sources */,
122+
);
123+
runOnlyForDeploymentPostprocessing = 0;
124+
};
125+
/* End PBXSourcesBuildPhase section */
126+
127+
/* Begin XCBuildConfiguration section */
128+
B4EDACF31C147BA1000AC60D /* Debug */ = {
129+
isa = XCBuildConfiguration;
130+
buildSettings = {
131+
ALWAYS_SEARCH_USER_PATHS = NO;
132+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
133+
CLANG_CXX_LIBRARY = "libc++";
134+
CLANG_ENABLE_MODULES = YES;
135+
CLANG_ENABLE_OBJC_ARC = YES;
136+
CLANG_WARN_BOOL_CONVERSION = YES;
137+
CLANG_WARN_CONSTANT_CONVERSION = YES;
138+
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
139+
CLANG_WARN_EMPTY_BODY = YES;
140+
CLANG_WARN_ENUM_CONVERSION = YES;
141+
CLANG_WARN_INT_CONVERSION = YES;
142+
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
143+
CLANG_WARN_UNREACHABLE_CODE = YES;
144+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
145+
CODE_SIGN_IDENTITY = "-";
146+
COPY_PHASE_STRIP = NO;
147+
DEBUG_INFORMATION_FORMAT = dwarf;
148+
ENABLE_STRICT_OBJC_MSGSEND = YES;
149+
ENABLE_TESTABILITY = YES;
150+
GCC_C_LANGUAGE_STANDARD = gnu99;
151+
GCC_DYNAMIC_NO_PIC = NO;
152+
GCC_NO_COMMON_BLOCKS = YES;
153+
GCC_OPTIMIZATION_LEVEL = 0;
154+
GCC_PREPROCESSOR_DEFINITIONS = (
155+
"DEBUG=1",
156+
"$(inherited)",
157+
);
158+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
159+
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
160+
GCC_WARN_UNDECLARED_SELECTOR = YES;
161+
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
162+
GCC_WARN_UNUSED_FUNCTION = YES;
163+
GCC_WARN_UNUSED_VARIABLE = YES;
164+
MACOSX_DEPLOYMENT_TARGET = 10.11;
165+
MTL_ENABLE_DEBUG_INFO = YES;
166+
ONLY_ACTIVE_ARCH = YES;
167+
SDKROOT = macosx;
168+
};
169+
name = Debug;
170+
};
171+
B4EDACF41C147BA1000AC60D /* Release */ = {
172+
isa = XCBuildConfiguration;
173+
buildSettings = {
174+
ALWAYS_SEARCH_USER_PATHS = NO;
175+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
176+
CLANG_CXX_LIBRARY = "libc++";
177+
CLANG_ENABLE_MODULES = YES;
178+
CLANG_ENABLE_OBJC_ARC = YES;
179+
CLANG_WARN_BOOL_CONVERSION = YES;
180+
CLANG_WARN_CONSTANT_CONVERSION = YES;
181+
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
182+
CLANG_WARN_EMPTY_BODY = YES;
183+
CLANG_WARN_ENUM_CONVERSION = YES;
184+
CLANG_WARN_INT_CONVERSION = YES;
185+
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
186+
CLANG_WARN_UNREACHABLE_CODE = YES;
187+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
188+
CODE_SIGN_IDENTITY = "-";
189+
COPY_PHASE_STRIP = NO;
190+
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
191+
ENABLE_NS_ASSERTIONS = NO;
192+
ENABLE_STRICT_OBJC_MSGSEND = YES;
193+
GCC_C_LANGUAGE_STANDARD = gnu99;
194+
GCC_NO_COMMON_BLOCKS = YES;
195+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
196+
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
197+
GCC_WARN_UNDECLARED_SELECTOR = YES;
198+
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
199+
GCC_WARN_UNUSED_FUNCTION = YES;
200+
GCC_WARN_UNUSED_VARIABLE = YES;
201+
MACOSX_DEPLOYMENT_TARGET = 10.11;
202+
MTL_ENABLE_DEBUG_INFO = NO;
203+
SDKROOT = macosx;
204+
};
205+
name = Release;
206+
};
207+
B4EDACF61C147BA1000AC60D /* Debug */ = {
208+
isa = XCBuildConfiguration;
209+
buildSettings = {
210+
PRODUCT_NAME = "$(TARGET_NAME)";
211+
};
212+
name = Debug;
213+
};
214+
B4EDACF71C147BA1000AC60D /* Release */ = {
215+
isa = XCBuildConfiguration;
216+
buildSettings = {
217+
PRODUCT_NAME = "$(TARGET_NAME)";
218+
};
219+
name = Release;
220+
};
221+
/* End XCBuildConfiguration section */
222+
223+
/* Begin XCConfigurationList section */
224+
B4EDACE91C147BA1000AC60D /* Build configuration list for PBXProject "Chap10_exercise" */ = {
225+
isa = XCConfigurationList;
226+
buildConfigurations = (
227+
B4EDACF31C147BA1000AC60D /* Debug */,
228+
B4EDACF41C147BA1000AC60D /* Release */,
229+
);
230+
defaultConfigurationIsVisible = 0;
231+
defaultConfigurationName = Release;
232+
};
233+
B4EDACF51C147BA1000AC60D /* Build configuration list for PBXNativeTarget "Chap10_exercise" */ = {
234+
isa = XCConfigurationList;
235+
buildConfigurations = (
236+
B4EDACF61C147BA1000AC60D /* Debug */,
237+
B4EDACF71C147BA1000AC60D /* Release */,
238+
);
239+
defaultConfigurationIsVisible = 0;
240+
};
241+
/* End XCConfigurationList section */
242+
};
243+
rootObject = B4EDACE61C147BA1000AC60D /* Project object */;
244+
}

Chap10_exercise/Chap10_exercise.xcodeproj/project.xcworkspace/contents.xcworkspacedata

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>SchemeUserState</key>
6+
<dict>
7+
<key>Chap10_exercise.xcscheme</key>
8+
<dict>
9+
<key>orderHint</key>
10+
<integer>0</integer>
11+
</dict>
12+
</dict>
13+
<key>SuppressBuildableAutocreation</key>
14+
<dict>
15+
<key>B4EDACED1C147BA1000AC60D</key>
16+
<dict>
17+
<key>primary</key>
18+
<true/>
19+
</dict>
20+
</dict>
21+
</dict>
22+
</plist>

liuyingbo/Chap10_exercise/main.m

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
//
2+
// main.m
3+
// Chap10_exercise
4+
//
5+
// Created by Yingbo Liu on 12/6/15.
6+
// Copyright © 2015 Yingbo Liu. All rights reserved.
7+
//
8+
9+
#pragma mark - exercise 1#
10+
11+
#import <Foundation/Foundation.h>
12+
@class XYPoint;
13+
@interface Rectangle: NSObject
14+
@property int width, height;
15+
-(XYPoint *) origin;
16+
-(void) setOrigin: (XYPoint *) pt;
17+
18+
-(id) setWidth: (int) w andHeight: (int) h;
19+
20+
-(int) area;
21+
-(int) perimeter;
22+
@end
23+
24+
25+
26+
@implementation Rectangle
27+
-(instanceType) setWidth: (int) w andHeight: (int) h{
28+
29+
self = [super int];
30+
31+
32+
if (self)
33+
[self setWidth:w andHeight:h ];
34+
35+
return self;
36+
}
37+
38+
@end
39+
40+
41+
42+
43+
#pragma mark - exercise 2#
44+
45+
@interface Rectangle, NSObject
46+
47+
48+
-(id) initWithSide:(int) side;
49+
50+
@end
51+
52+
53+
@implementation Rectangle
54+
55+
-(id) initWithSide:(int) side{
56+
57+
self = [super initWithSide];
58+
if (self){
59+
60+
61+
[self initWithSide];
62+
63+
}
64+
return self;
65+
66+
}
67+
68+
@end
69+
70+
#pragma mark - exercise 3#
71+
//How can you retrieve the value of the counter
72+
//We could have a local static variable that would be set to only
73+
//once when the program started. It would retain its value through
74+
//successive invocations of the method.Everytime the method is
75+
//called, the counter will increment by one
76+
77+
78+
#pragma mark - exercise 4#
79+
80+
81+
enum Day { Sunday, Monday, Tuesday, Wednesday, Thrusday, Friday, Saturday}
82+
83+
typedef Int Day;
84+
85+
Day number;
86+
87+
88+
89+
90+
#pragma mark - exercise 5#
91+
92+
93+
enum FractionObj {f1 = [[Fraction alloc] init],f2 = [[Fraction alloc] init]};
94+
typedef NSString FractionObj;
95+
96+
FractionObj newFractions;
97+
98+
99+
100+
#pragma mark - exercise 6#
101+
102+
float f = 1.00;
103+
short int i = 100;
104+
long int l = 500L;
105+
double d = 15.00;
106+
107+
f + i = 101.00000 float
108+
l / d = 33.3333 float
109+
l + f = 501.00000 float
110+
l * i = 50000 long
111+
f / 2 =0.5000000 float
112+
i / (d + f) = 6.25000 float
113+
l / (i * 2.0) =0.50000 float
114+
l + i / (double) l = 4136 double
115+
116+

0 commit comments

Comments
 (0)