diff --git a/Week1/APLOC2 Week 1/APLOC2 Week 1.xcodeproj/project.pbxproj b/Week1/APLOC2 Week 1/APLOC2 Week 1.xcodeproj/project.pbxproj index 39f97bf..2855519 100644 --- a/Week1/APLOC2 Week 1/APLOC2 Week 1.xcodeproj/project.pbxproj +++ b/Week1/APLOC2 Week 1/APLOC2 Week 1.xcodeproj/project.pbxproj @@ -23,6 +23,7 @@ 65DF924016C479840035C5C9 /* ChildFactory.m in Sources */ = {isa = PBXBuildFile; fileRef = 65DF923F16C479840035C5C9 /* ChildFactory.m */; }; 65DF924316C49D240035C5C9 /* GoodChild.m in Sources */ = {isa = PBXBuildFile; fileRef = 65DF924216C49D240035C5C9 /* GoodChild.m */; }; 65DF924916C4A89C0035C5C9 /* BadChild.m in Sources */ = {isa = PBXBuildFile; fileRef = 65DF924816C4A89C0035C5C9 /* BadChild.m */; }; + 65DF924C16C4AE670035C5C9 /* RottenChild.m in Sources */ = {isa = PBXBuildFile; fileRef = 65DF924B16C4AE670035C5C9 /* RottenChild.m */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -51,6 +52,8 @@ 65DF924216C49D240035C5C9 /* GoodChild.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GoodChild.m; sourceTree = ""; }; 65DF924716C4A89C0035C5C9 /* BadChild.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BadChild.h; sourceTree = ""; }; 65DF924816C4A89C0035C5C9 /* BadChild.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BadChild.m; sourceTree = ""; }; + 65DF924A16C4AE670035C5C9 /* RottenChild.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RottenChild.h; sourceTree = ""; }; + 65DF924B16C4AE670035C5C9 /* RottenChild.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RottenChild.m; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -112,6 +115,8 @@ 65DF924216C49D240035C5C9 /* GoodChild.m */, 65DF924716C4A89C0035C5C9 /* BadChild.h */, 65DF924816C4A89C0035C5C9 /* BadChild.m */, + 65DF924A16C4AE670035C5C9 /* RottenChild.h */, + 65DF924B16C4AE670035C5C9 /* RottenChild.m */, ); path = "APLOC2 Week 1"; sourceTree = ""; @@ -204,6 +209,7 @@ 65DF924016C479840035C5C9 /* ChildFactory.m in Sources */, 65DF924316C49D240035C5C9 /* GoodChild.m in Sources */, 65DF924916C4A89C0035C5C9 /* BadChild.m in Sources */, + 65DF924C16C4AE670035C5C9 /* RottenChild.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Week1/APLOC2 Week 1/APLOC2 Week 1.xcodeproj/project.xcworkspace/xcuserdata/notmyemail.xcuserdatad/UserInterfaceState.xcuserstate b/Week1/APLOC2 Week 1/APLOC2 Week 1.xcodeproj/project.xcworkspace/xcuserdata/notmyemail.xcuserdatad/UserInterfaceState.xcuserstate index 11892f7..436c872 100644 Binary files a/Week1/APLOC2 Week 1/APLOC2 Week 1.xcodeproj/project.xcworkspace/xcuserdata/notmyemail.xcuserdatad/UserInterfaceState.xcuserstate and b/Week1/APLOC2 Week 1/APLOC2 Week 1.xcodeproj/project.xcworkspace/xcuserdata/notmyemail.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Week1/APLOC2 Week 1/APLOC2 Week 1/Child.h b/Week1/APLOC2 Week 1/APLOC2 Week 1/Child.h index fe18410..96ffe38 100644 --- a/Week1/APLOC2 Week 1/APLOC2 Week 1/Child.h +++ b/Week1/APLOC2 Week 1/APLOC2 Week 1/Child.h @@ -19,7 +19,7 @@ typedef enum @interface Child : NSObject { -@protected +@public NSString *strName; int intChild; EChildType childType; diff --git a/Week1/APLOC2 Week 1/APLOC2 Week 1/Child.m b/Week1/APLOC2 Week 1/APLOC2 Week 1/Child.m index b0f5522..3502009 100644 --- a/Week1/APLOC2 Week 1/APLOC2 Week 1/Child.m +++ b/Week1/APLOC2 Week 1/APLOC2 Week 1/Child.m @@ -27,6 +27,7 @@ -(void)showName { NSLog(@"My name is %@", strName); + } @@ -34,7 +35,7 @@ -(NSString*)showChild { - NSString* returnThis = [[NSString alloc] initWithFormat:@"intChild = %d", intChild]; + NSString* returnThis = [[NSString alloc] initWithFormat:@"My name is = %@", strName]; /* NSString* returnThis = [[NSString alloc] initWithFormat:@"blnChild = %c", blnChild]; diff --git a/Week1/APLOC2 Week 1/APLOC2 Week 1/ChildFactory.m b/Week1/APLOC2 Week 1/APLOC2 Week 1/ChildFactory.m index b57a48f..60848ef 100644 --- a/Week1/APLOC2 Week 1/APLOC2 Week 1/ChildFactory.m +++ b/Week1/APLOC2 Week 1/APLOC2 Week 1/ChildFactory.m @@ -21,6 +21,11 @@ { return [[Child alloc] initWithDetails:1 inpStrName:@"Connor"]; } + else if (childType == 3) + { + return [[Child alloc] initWithDetails:3 inpStrName:@"Brent"]; + } + return nil; } diff --git a/Week1/APLOC2 Week 1/APLOC2 Week 1/GoodChild.m b/Week1/APLOC2 Week 1/APLOC2 Week 1/GoodChild.m index df92df0..5d2a63b 100644 --- a/Week1/APLOC2 Week 1/APLOC2 Week 1/GoodChild.m +++ b/Week1/APLOC2 Week 1/APLOC2 Week 1/GoodChild.m @@ -15,5 +15,6 @@ { intChild = 0; strName = @"Jack"; + childType = CHILDTYPE_GOOD; } @end diff --git a/Week1/APLOC2 Week 1/APLOC2 Week 1/RottenChild.h b/Week1/APLOC2 Week 1/APLOC2 Week 1/RottenChild.h new file mode 100644 index 0000000..7b6ce20 --- /dev/null +++ b/Week1/APLOC2 Week 1/APLOC2 Week 1/RottenChild.h @@ -0,0 +1,16 @@ +// +// RottenChild.h +// APLOC2 Week 1 +// +// Created by Brent Marohnic on 2/7/13. +// Copyright (c) 2013 Brent Marohnic. All rights reserved. +// + +#import +#import "Child.h" + +@interface RottenChild : Child + +-(void)setAttributes; + +@end diff --git a/Week1/APLOC2 Week 1/APLOC2 Week 1/RottenChild.m b/Week1/APLOC2 Week 1/APLOC2 Week 1/RottenChild.m new file mode 100644 index 0000000..18d6f54 --- /dev/null +++ b/Week1/APLOC2 Week 1/APLOC2 Week 1/RottenChild.m @@ -0,0 +1,19 @@ +// +// RottenChild.m +// APLOC2 Week 1 +// +// Created by Brent Marohnic on 2/7/13. +// Copyright (c) 2013 Brent Marohnic. All rights reserved. +// + +#import "RottenChild.h" +#import "Child.h" + +@implementation RottenChild + +-(void)setAttributes +{ + intChild = 3; + strName = @"Brent"; +} +@end diff --git a/Week1/APLOC2 Week 1/APLOC2 Week 1/ViewController.m b/Week1/APLOC2 Week 1/APLOC2 Week 1/ViewController.m index 10f1dbd..b1e5f8e 100644 --- a/Week1/APLOC2 Week 1/APLOC2 Week 1/ViewController.m +++ b/Week1/APLOC2 Week 1/APLOC2 Week 1/ViewController.m @@ -10,6 +10,8 @@ #import "Child.h" #import "ChildFactory.h" #import "GoodChild.h" +#import "BadChild.h" +#import "RottenChild.h" @interface ViewController () @@ -28,6 +30,8 @@ [Jack showName]; } + + //Instantiate instances of the subclasses and set their attributes GoodChild *goodChild = [[GoodChild alloc] init]; { if (goodChild != nil) @@ -36,9 +40,30 @@ } } + BadChild *badChild = [[BadChild alloc] init]; + { + if (badChild != nil) + { + [badChild setAttributes]; + } + } + + RottenChild *rottenChild = [[RottenChild alloc] init]; + { + if (rottenChild != nil) + { + [rottenChild setAttributes]; + } + } + + + + [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. + //Setup the labels that will hold the static and dynamic values + firstLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 50)]; secondLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 51, 320, 50)]; @@ -58,8 +83,14 @@ } firstLabel.text = @"Good Child"; + secondLabel.text = goodChild->strName; thirdLabel.text = @"Bad Child"; + fourthLabel.text = badChild->strName; fifthLabel.text = @"Rotten Child"; + sixthLabel.text = rottenChild->strName; + + + //Show the labels [self.view addSubview:firstLabel]; [self.view addSubview:secondLabel];