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 46be22b..39f97bf 100644 --- a/Week1/APLOC2 Week 1/APLOC2 Week 1.xcodeproj/project.pbxproj +++ b/Week1/APLOC2 Week 1/APLOC2 Week 1.xcodeproj/project.pbxproj @@ -20,6 +20,9 @@ 65DF923216C3B0810035C5C9 /* ViewController_iPhone.xib in Resources */ = {isa = PBXBuildFile; fileRef = 65DF923016C3B0810035C5C9 /* ViewController_iPhone.xib */; }; 65DF923516C3B0810035C5C9 /* ViewController_iPad.xib in Resources */ = {isa = PBXBuildFile; fileRef = 65DF923316C3B0810035C5C9 /* ViewController_iPad.xib */; }; 65DF923D16C3B2CB0035C5C9 /* Child.m in Sources */ = {isa = PBXBuildFile; fileRef = 65DF923C16C3B2CB0035C5C9 /* Child.m */; }; + 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 */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -42,6 +45,12 @@ 65DF923416C3B0810035C5C9 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/ViewController_iPad.xib; sourceTree = ""; }; 65DF923B16C3B2CB0035C5C9 /* Child.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Child.h; sourceTree = ""; }; 65DF923C16C3B2CB0035C5C9 /* Child.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Child.m; sourceTree = ""; }; + 65DF923E16C479840035C5C9 /* ChildFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChildFactory.h; sourceTree = ""; }; + 65DF923F16C479840035C5C9 /* ChildFactory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChildFactory.m; sourceTree = ""; }; + 65DF924116C49D240035C5C9 /* GoodChild.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GoodChild.h; sourceTree = ""; }; + 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 = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -97,6 +106,12 @@ 65DF921C16C3B0810035C5C9 /* Supporting Files */, 65DF923B16C3B2CB0035C5C9 /* Child.h */, 65DF923C16C3B2CB0035C5C9 /* Child.m */, + 65DF923E16C479840035C5C9 /* ChildFactory.h */, + 65DF923F16C479840035C5C9 /* ChildFactory.m */, + 65DF924116C49D240035C5C9 /* GoodChild.h */, + 65DF924216C49D240035C5C9 /* GoodChild.m */, + 65DF924716C4A89C0035C5C9 /* BadChild.h */, + 65DF924816C4A89C0035C5C9 /* BadChild.m */, ); path = "APLOC2 Week 1"; sourceTree = ""; @@ -186,6 +201,9 @@ 65DF922616C3B0810035C5C9 /* AppDelegate.m in Sources */, 65DF922F16C3B0810035C5C9 /* ViewController.m in Sources */, 65DF923D16C3B2CB0035C5C9 /* Child.m in Sources */, + 65DF924016C479840035C5C9 /* ChildFactory.m in Sources */, + 65DF924316C49D240035C5C9 /* GoodChild.m in Sources */, + 65DF924916C4A89C0035C5C9 /* BadChild.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 f8c2efb..11892f7 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/BadChild.h b/Week1/APLOC2 Week 1/APLOC2 Week 1/BadChild.h new file mode 100644 index 0000000..af7e1bb --- /dev/null +++ b/Week1/APLOC2 Week 1/APLOC2 Week 1/BadChild.h @@ -0,0 +1,16 @@ +// +// BadChild.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 BadChild : Child + +-(void)setAttributes; + +@end diff --git a/Week1/APLOC2 Week 1/APLOC2 Week 1/BadChild.m b/Week1/APLOC2 Week 1/APLOC2 Week 1/BadChild.m new file mode 100644 index 0000000..4328050 --- /dev/null +++ b/Week1/APLOC2 Week 1/APLOC2 Week 1/BadChild.m @@ -0,0 +1,19 @@ +// +// BadChild.m +// APLOC2 Week 1 +// +// Created by Brent Marohnic on 2/7/13. +// Copyright (c) 2013 Brent Marohnic. All rights reserved. +// + +#import "BadChild.h" +#import "Child.h" + +@implementation BadChild + +-(void)setAttributes +{ + intChild = 1; + strName = @"Connor"; +} +@end diff --git a/Week1/APLOC2 Week 1/APLOC2 Week 1/Child.h b/Week1/APLOC2 Week 1/APLOC2 Week 1/Child.h index cf5ca13..fe18410 100644 --- a/Week1/APLOC2 Week 1/APLOC2 Week 1/Child.h +++ b/Week1/APLOC2 Week 1/APLOC2 Week 1/Child.h @@ -8,14 +8,27 @@ #import +typedef enum +{ + CHILDTYPE_GOOD=0, + CHILDTYPE_BAD, + CHILDTYPE_PERFECT, + CHILDTYPE_ROTTEN + +} EChildType; + @interface Child : NSObject { +@protected + NSString *strName; int intChild; - float fltChild; - BOOL blnChild; - + EChildType childType; } +-(id)initWithDetails:(int)inpIntChild inpStrName:(NSString*)inpStrName; + +-(void)showName; + -(NSString*)showChild; @property int intChild; diff --git a/Week1/APLOC2 Week 1/APLOC2 Week 1/Child.m b/Week1/APLOC2 Week 1/APLOC2 Week 1/Child.m index 9cce8a5..b0f5522 100644 --- a/Week1/APLOC2 Week 1/APLOC2 Week 1/Child.m +++ b/Week1/APLOC2 Week 1/APLOC2 Week 1/Child.m @@ -11,23 +11,30 @@ @implementation Child @synthesize intChild; --(id)init +-(id)initWithDetails:(int)inpIntChild inpStrName:(NSString*)inpStrName { self = [super init]; if (self != nil) { - intChild = 1; - fltChild = 150.69; - blnChild = TRUE; + strName = inpStrName; + intChild = inpIntChild ; + } return self; } +-(void)showName +{ + NSLog(@"My name is %@", strName); +} + + + -(NSString*)showChild { - NSString* returnThis = [[NSString alloc] initWithFormat:@"intChild = %d, fltChild = %1.2f, blnChild = %c", intChild, fltChild, blnChild]; + NSString* returnThis = [[NSString alloc] initWithFormat:@"intChild = %d", intChild]; /* NSString* returnThis = [[NSString alloc] initWithFormat:@"blnChild = %c", blnChild]; diff --git a/Week1/APLOC2 Week 1/APLOC2 Week 1/ChildFactory.h b/Week1/APLOC2 Week 1/APLOC2 Week 1/ChildFactory.h new file mode 100644 index 0000000..a93f4ba --- /dev/null +++ b/Week1/APLOC2 Week 1/APLOC2 Week 1/ChildFactory.h @@ -0,0 +1,16 @@ +// +// ChildFactory.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 ChildFactory : NSObject + +-(Child*)GetChild:(int)childType; + +@end diff --git a/Week1/APLOC2 Week 1/APLOC2 Week 1/ChildFactory.m b/Week1/APLOC2 Week 1/APLOC2 Week 1/ChildFactory.m new file mode 100644 index 0000000..b57a48f --- /dev/null +++ b/Week1/APLOC2 Week 1/APLOC2 Week 1/ChildFactory.m @@ -0,0 +1,27 @@ +// +// ChildFactory.m +// APLOC2 Week 1 +// +// Created by Brent Marohnic on 2/7/13. +// Copyright (c) 2013 Brent Marohnic. All rights reserved. +// + +#import "ChildFactory.h" +#import "Child.h" + +@implementation ChildFactory + +-(Child*)GetChild:(int)childType +{ + if (childType == 0) + { + return [[Child alloc] initWithDetails:0 inpStrName:@"Jack"]; + } + else if (childType == 1) + { + return [[Child alloc] initWithDetails:1 inpStrName:@"Connor"]; + } + return nil; + +} +@end diff --git a/Week1/APLOC2 Week 1/APLOC2 Week 1/GoodChild.h b/Week1/APLOC2 Week 1/APLOC2 Week 1/GoodChild.h new file mode 100644 index 0000000..2379714 --- /dev/null +++ b/Week1/APLOC2 Week 1/APLOC2 Week 1/GoodChild.h @@ -0,0 +1,16 @@ +// +// GoodChild.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 GoodChild : Child + +-(void)setAttributes; + +@end diff --git a/Week1/APLOC2 Week 1/APLOC2 Week 1/GoodChild.m b/Week1/APLOC2 Week 1/APLOC2 Week 1/GoodChild.m new file mode 100644 index 0000000..df92df0 --- /dev/null +++ b/Week1/APLOC2 Week 1/APLOC2 Week 1/GoodChild.m @@ -0,0 +1,19 @@ +// +// GoodChild.m +// APLOC2 Week 1 +// +// Created by Brent Marohnic on 2/7/13. +// Copyright (c) 2013 Brent Marohnic. All rights reserved. +// + +#import "GoodChild.h" +#import "Child.h" + +@implementation GoodChild + +-(void)setAttributes +{ + intChild = 0; + strName = @"Jack"; +} +@end diff --git a/Week1/APLOC2 Week 1/APLOC2 Week 1/ViewController.h b/Week1/APLOC2 Week 1/APLOC2 Week 1/ViewController.h index 87b94e9..742f651 100644 --- a/Week1/APLOC2 Week 1/APLOC2 Week 1/ViewController.h +++ b/Week1/APLOC2 Week 1/APLOC2 Week 1/ViewController.h @@ -12,5 +12,10 @@ @interface ViewController : UIViewController { UILabel *firstLabel; + UILabel *secondLabel; + UILabel *thirdLabel; + UILabel *fourthLabel; + UILabel *fifthLabel; + UILabel *sixthLabel; } @end diff --git a/Week1/APLOC2 Week 1/APLOC2 Week 1/ViewController.m b/Week1/APLOC2 Week 1/APLOC2 Week 1/ViewController.m index e5b7e49..10f1dbd 100644 --- a/Week1/APLOC2 Week 1/APLOC2 Week 1/ViewController.m +++ b/Week1/APLOC2 Week 1/APLOC2 Week 1/ViewController.m @@ -8,6 +8,8 @@ #import "ViewController.h" #import "Child.h" +#import "ChildFactory.h" +#import "GoodChild.h" @interface ViewController () @@ -17,22 +19,56 @@ - (void)viewDidLoad { + + ChildFactory *childFactory = [[ChildFactory alloc] init]; + if (childFactory != nil) + { + Child *Jack = [childFactory GetChild:0]; + + [Jack showName]; + } + + GoodChild *goodChild = [[GoodChild alloc] init]; + { + if (goodChild != nil) + { + [goodChild setAttributes]; + } + } + [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. - firstLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 200)]; - firstLabel.numberOfLines = 2; + firstLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 50)]; + secondLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 51, 320, 50)]; + + thirdLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 120, 320, 50)]; + fourthLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 171, 320, 50)]; + + fifthLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 240, 320, 50)]; + sixthLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 291, 320, 50)]; Child *firstChild = [[Child alloc] init]; if (firstChild != nil) { firstChild.intChild = 2; - firstLabel.text = firstChild.showChild; + secondLabel.text = firstChild.showChild; } + firstLabel.text = @"Good Child"; + thirdLabel.text = @"Bad Child"; + fifthLabel.text = @"Rotten Child"; + [self.view addSubview:firstLabel]; + [self.view addSubview:secondLabel]; + + [self.view addSubview:thirdLabel]; + [self.view addSubview:fourthLabel]; + + [self.view addSubview:fifthLabel]; + [self.view addSubview:sixthLabel]; }