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 2855519..a1c5ea8 100644 --- a/Week1/APLOC2 Week 1/APLOC2 Week 1.xcodeproj/project.pbxproj +++ b/Week1/APLOC2 Week 1/APLOC2 Week 1.xcodeproj/project.pbxproj @@ -7,6 +7,11 @@ objects = { /* Begin PBXBuildFile section */ + 658F737B16C9C10400092386 /* insectFactory.m in Sources */ = {isa = PBXBuildFile; fileRef = 658F737A16C9C10400092386 /* insectFactory.m */; }; + 658F737E16C9C12D00092386 /* baseInsect.m in Sources */ = {isa = PBXBuildFile; fileRef = 658F737D16C9C12D00092386 /* baseInsect.m */; }; + 658F738116C9C18500092386 /* cricketInsect.m in Sources */ = {isa = PBXBuildFile; fileRef = 658F738016C9C18500092386 /* cricketInsect.m */; }; + 658F738416C9C19F00092386 /* butterflyInsect.m in Sources */ = {isa = PBXBuildFile; fileRef = 658F738316C9C19F00092386 /* butterflyInsect.m */; }; + 658F738716C9C1AF00092386 /* antInsect.m in Sources */ = {isa = PBXBuildFile; fileRef = 658F738616C9C1AF00092386 /* antInsect.m */; }; 65DF921616C3B0810035C5C9 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 65DF921516C3B0810035C5C9 /* UIKit.framework */; }; 65DF921816C3B0810035C5C9 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 65DF921716C3B0810035C5C9 /* Foundation.framework */; }; 65DF921A16C3B0810035C5C9 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 65DF921916C3B0810035C5C9 /* CoreGraphics.framework */; }; @@ -19,14 +24,19 @@ 65DF922F16C3B0810035C5C9 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 65DF922E16C3B0810035C5C9 /* ViewController.m */; }; 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 */; }; - 65DF924C16C4AE670035C5C9 /* RottenChild.m in Sources */ = {isa = PBXBuildFile; fileRef = 65DF924B16C4AE670035C5C9 /* RottenChild.m */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 658F737916C9C10400092386 /* insectFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = insectFactory.h; sourceTree = ""; }; + 658F737A16C9C10400092386 /* insectFactory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = insectFactory.m; sourceTree = ""; }; + 658F737C16C9C12D00092386 /* baseInsect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = baseInsect.h; sourceTree = ""; }; + 658F737D16C9C12D00092386 /* baseInsect.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = baseInsect.m; sourceTree = ""; }; + 658F737F16C9C18500092386 /* cricketInsect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cricketInsect.h; sourceTree = ""; }; + 658F738016C9C18500092386 /* cricketInsect.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = cricketInsect.m; sourceTree = ""; }; + 658F738216C9C19F00092386 /* butterflyInsect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = butterflyInsect.h; sourceTree = ""; }; + 658F738316C9C19F00092386 /* butterflyInsect.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = butterflyInsect.m; sourceTree = ""; }; + 658F738516C9C1AF00092386 /* antInsect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = antInsect.h; sourceTree = ""; }; + 658F738616C9C1AF00092386 /* antInsect.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = antInsect.m; sourceTree = ""; }; 65DF921216C3B0810035C5C9 /* APLOC2 Week 1.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "APLOC2 Week 1.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 65DF921516C3B0810035C5C9 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 65DF921716C3B0810035C5C9 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; @@ -44,16 +54,6 @@ 65DF922E16C3B0810035C5C9 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 65DF923116C3B0810035C5C9 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/ViewController_iPhone.xib; sourceTree = ""; }; 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 = ""; }; - 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 */ @@ -107,16 +107,16 @@ 65DF923016C3B0810035C5C9 /* ViewController_iPhone.xib */, 65DF923316C3B0810035C5C9 /* ViewController_iPad.xib */, 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 */, - 65DF924A16C4AE670035C5C9 /* RottenChild.h */, - 65DF924B16C4AE670035C5C9 /* RottenChild.m */, + 658F737916C9C10400092386 /* insectFactory.h */, + 658F737A16C9C10400092386 /* insectFactory.m */, + 658F737C16C9C12D00092386 /* baseInsect.h */, + 658F737D16C9C12D00092386 /* baseInsect.m */, + 658F737F16C9C18500092386 /* cricketInsect.h */, + 658F738016C9C18500092386 /* cricketInsect.m */, + 658F738216C9C19F00092386 /* butterflyInsect.h */, + 658F738316C9C19F00092386 /* butterflyInsect.m */, + 658F738516C9C1AF00092386 /* antInsect.h */, + 658F738616C9C1AF00092386 /* antInsect.m */, ); path = "APLOC2 Week 1"; sourceTree = ""; @@ -205,11 +205,11 @@ 65DF922216C3B0810035C5C9 /* main.m in Sources */, 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 */, - 65DF924C16C4AE670035C5C9 /* RottenChild.m in Sources */, + 658F737B16C9C10400092386 /* insectFactory.m in Sources */, + 658F737E16C9C12D00092386 /* baseInsect.m in Sources */, + 658F738116C9C18500092386 /* cricketInsect.m in Sources */, + 658F738416C9C19F00092386 /* butterflyInsect.m in Sources */, + 658F738716C9C1AF00092386 /* antInsect.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -342,6 +342,7 @@ 65DF923A16C3B0810035C5C9 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; 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 436c872..233d61b 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 deleted file mode 100644 index af7e1bb..0000000 --- a/Week1/APLOC2 Week 1/APLOC2 Week 1/BadChild.h +++ /dev/null @@ -1,16 +0,0 @@ -// -// 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 deleted file mode 100644 index 4328050..0000000 --- a/Week1/APLOC2 Week 1/APLOC2 Week 1/BadChild.m +++ /dev/null @@ -1,19 +0,0 @@ -// -// 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 deleted file mode 100644 index 96ffe38..0000000 --- a/Week1/APLOC2 Week 1/APLOC2 Week 1/Child.h +++ /dev/null @@ -1,36 +0,0 @@ -// -// Child.h -// APLOC2 Week 1 -// -// Created by Brent Marohnic on 2/7/13. -// Copyright (c) 2013 Brent Marohnic. All rights reserved. -// - -#import - -typedef enum -{ - CHILDTYPE_GOOD=0, - CHILDTYPE_BAD, - CHILDTYPE_PERFECT, - CHILDTYPE_ROTTEN - -} EChildType; - -@interface Child : NSObject -{ -@public - NSString *strName; - int intChild; - EChildType childType; -} - --(id)initWithDetails:(int)inpIntChild inpStrName:(NSString*)inpStrName; - --(void)showName; - --(NSString*)showChild; - -@property int intChild; - -@end diff --git a/Week1/APLOC2 Week 1/APLOC2 Week 1/Child.m b/Week1/APLOC2 Week 1/APLOC2 Week 1/Child.m deleted file mode 100644 index 3502009..0000000 --- a/Week1/APLOC2 Week 1/APLOC2 Week 1/Child.m +++ /dev/null @@ -1,48 +0,0 @@ -// -// Child.m -// APLOC2 Week 1 -// -// Created by Brent Marohnic on 2/7/13. -// Copyright (c) 2013 Brent Marohnic. All rights reserved. -// - -#import "Child.h" - -@implementation Child -@synthesize intChild; - --(id)initWithDetails:(int)inpIntChild inpStrName:(NSString*)inpStrName -{ - self = [super init]; - if (self != nil) - { - strName = inpStrName; - intChild = inpIntChild ; - - } - - return self; -} - --(void)showName -{ - NSLog(@"My name is %@", strName); - -} - - - - --(NSString*)showChild -{ - NSString* returnThis = [[NSString alloc] initWithFormat:@"My name is = %@", strName]; - - - /* NSString* returnThis = [[NSString alloc] initWithFormat:@"blnChild = %c", blnChild]; - */ - - return returnThis; - -} - -@end diff --git a/Week1/APLOC2 Week 1/APLOC2 Week 1/ChildFactory.h b/Week1/APLOC2 Week 1/APLOC2 Week 1/ChildFactory.h deleted file mode 100644 index a93f4ba..0000000 --- a/Week1/APLOC2 Week 1/APLOC2 Week 1/ChildFactory.h +++ /dev/null @@ -1,16 +0,0 @@ -// -// 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 deleted file mode 100644 index 60848ef..0000000 --- a/Week1/APLOC2 Week 1/APLOC2 Week 1/ChildFactory.m +++ /dev/null @@ -1,32 +0,0 @@ -// -// 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"]; - } - else if (childType == 3) - { - return [[Child alloc] initWithDetails:3 inpStrName:@"Brent"]; - } - - 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 deleted file mode 100644 index 2379714..0000000 --- a/Week1/APLOC2 Week 1/APLOC2 Week 1/GoodChild.h +++ /dev/null @@ -1,16 +0,0 @@ -// -// 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 deleted file mode 100644 index 5d2a63b..0000000 --- a/Week1/APLOC2 Week 1/APLOC2 Week 1/GoodChild.m +++ /dev/null @@ -1,20 +0,0 @@ -// -// 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"; - 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 deleted file mode 100644 index 7b6ce20..0000000 --- a/Week1/APLOC2 Week 1/APLOC2 Week 1/RottenChild.h +++ /dev/null @@ -1,16 +0,0 @@ -// -// 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 deleted file mode 100644 index 18d6f54..0000000 --- a/Week1/APLOC2 Week 1/APLOC2 Week 1/RottenChild.m +++ /dev/null @@ -1,19 +0,0 @@ -// -// 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.h b/Week1/APLOC2 Week 1/APLOC2 Week 1/ViewController.h index 742f651..191fb62 100644 --- a/Week1/APLOC2 Week 1/APLOC2 Week 1/ViewController.h +++ b/Week1/APLOC2 Week 1/APLOC2 Week 1/ViewController.h @@ -7,7 +7,7 @@ // #import -@class Child; +#import "insectFactory.h" @interface ViewController : UIViewController { diff --git a/Week1/APLOC2 Week 1/APLOC2 Week 1/ViewController.m b/Week1/APLOC2 Week 1/APLOC2 Week 1/ViewController.m index b1e5f8e..2c0ec87 100644 --- a/Week1/APLOC2 Week 1/APLOC2 Week 1/ViewController.m +++ b/Week1/APLOC2 Week 1/APLOC2 Week 1/ViewController.m @@ -7,11 +7,7 @@ // #import "ViewController.h" -#import "Child.h" -#import "ChildFactory.h" -#import "GoodChild.h" -#import "BadChild.h" -#import "RottenChild.h" + @interface ViewController () @@ -21,43 +17,22 @@ - (void)viewDidLoad { + // create a cricket + cricketInsect *myNewCricket = (cricketInsect*)[insectFactory createNewInsect:CRICKET]; + [myNewCricket setSleepDerprivationLevel:5]; - ChildFactory *childFactory = [[ChildFactory alloc] init]; - if (childFactory != nil) - { - Child *Jack = [childFactory GetChild:0]; - - [Jack showName]; - } + [myNewCricket calculateAnnoyanceFactor]; + // create a butterfly + butterflyInsect *myNewButterfly = (butterflyInsect*)[insectFactory createNewInsect:BUTTERFLY]; - //Instantiate instances of the subclasses and set their attributes - GoodChild *goodChild = [[GoodChild alloc] init]; - { - if (goodChild != nil) - { - [goodChild setAttributes]; - } - } - - BadChild *badChild = [[BadChild alloc] init]; - { - if (badChild != nil) - { - [badChild setAttributes]; - } - } - - RottenChild *rottenChild = [[RottenChild alloc] init]; - { - if (rottenChild != nil) - { - [rottenChild setAttributes]; - } - } - + [myNewButterfly calculateAnnoyanceFactor]; + // create a ant + antInsect *myNewAnt = (antInsect*)[insectFactory createNewInsect:ANT]; + [myNewAnt setTypeOfAnt:RED]; + [myNewAnt calculateAnnoyanceFactor]; [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. @@ -67,27 +42,21 @@ 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)]; + thirdLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 170, 320, 50)]; + fourthLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 221, 320, 50)]; - fifthLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 240, 320, 50)]; - sixthLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 291, 320, 50)]; + fifthLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 340, 320, 50)]; + sixthLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 391, 320, 50)]; - Child *firstChild = [[Child alloc] init]; - if (firstChild != nil) - { - firstChild.intChild = 2; - - secondLabel.text = firstChild.showChild; - - } - firstLabel.text = @"Good Child"; - secondLabel.text = goodChild->strName; - thirdLabel.text = @"Bad Child"; - fourthLabel.text = badChild->strName; - fifthLabel.text = @"Rotten Child"; - sixthLabel.text = rottenChild->strName; + firstLabel.text = [NSString stringWithFormat:@"A %@ has been created.", [myNewCricket insectName]]; + secondLabel.numberOfLines = 2; + secondLabel.text = [NSString stringWithFormat:@"Its annoyance factor is %d when my sleep deprivation is %d", [myNewCricket annoyanceFactor], [myNewCricket sleepDerprivationLevel]]; + thirdLabel.text = [NSString stringWithFormat:@"A %@ has been created.", [myNewButterfly insectName]]; + fourthLabel.text = [NSString stringWithFormat:@"Its annoyance factor is %d simply because I like butterflies.", [myNewButterfly annoyanceFactor]]; + fourthLabel.numberOfLines = 2; + fifthLabel.text = [NSString stringWithFormat:@"A %@ has been created.", [myNewAnt insectName]]; + sixthLabel.text = [NSString stringWithFormat:@"Its annoyance factor is %d", [myNewAnt annoyanceFactor]]; //Show the labels diff --git a/Week1/APLOC2 Week 1/APLOC2 Week 1/antInsect.h b/Week1/APLOC2 Week 1/APLOC2 Week 1/antInsect.h new file mode 100644 index 0000000..072c571 --- /dev/null +++ b/Week1/APLOC2 Week 1/APLOC2 Week 1/antInsect.h @@ -0,0 +1,28 @@ +// +// antInsect.h +// APLOC2 Week 1 +// +// Created by Brent Marohnic on 2/11/13. +// Copyright (c) 2013 Brent Marohnic. All rights reserved. +// + +#import "baseInsect.h" + +@interface antInsect : baseInsect +{ + int antType; +} + +typedef enum +{ + BLACK, + RED, + CARPENTER +} antType; + +// insect specific data members used to calculate overall insect annoyance level +@property int homeInvader; +@property int sheerNumber; +@property int typeOfAnt; + +@end diff --git a/Week1/APLOC2 Week 1/APLOC2 Week 1/antInsect.m b/Week1/APLOC2 Week 1/APLOC2 Week 1/antInsect.m new file mode 100644 index 0000000..d674628 --- /dev/null +++ b/Week1/APLOC2 Week 1/APLOC2 Week 1/antInsect.m @@ -0,0 +1,60 @@ +// +// antInsect.m +// APLOC2 Week 1 +// +// Created by Brent Marohnic on 2/11/13. +// Copyright (c) 2013 Brent Marohnic. All rights reserved. +// + +#import "antInsect.h" + +@implementation antInsect + +@synthesize homeInvader, sheerNumber, typeOfAnt; + +// set unique data members from within INIT + +-(id)init +{ + self = [super init]; + if (self != nil) + { + [self setInsectName:@"ant"]; + [self setTypeOfAnt:CARPENTER]; + [self setHomeInvader: 8]; + [self setSheerNumber: 9]; + + } + return self; +} + + +// override the base insect method +-(int)calculateAnnoyanceFactor +{ + if (typeOfAnt == BLACK) + { + [self setAnnoyanceFactor:self.homeInvader + self.sheerNumber - 2]; + [self setInsectName:@"black ant"]; + } + else if (typeOfAnt == RED) + { + [self setAnnoyanceFactor:self.homeInvader + self.sheerNumber + 0]; + [self setInsectName:@"red ant"]; + } + else if (typeOfAnt == CARPENTER) + { + [self setAnnoyanceFactor:self.homeInvader + self.sheerNumber + 2]; + [self setInsectName:@"carpenter ant"]; + } + else + { + NSLog(@"Please specify a valid type of ant."); + } + + NSLog(@"The ant has an annoyance factor of %i out of 20.", self.annoyanceFactor); + return self.annoyanceFactor; +} + + +@end diff --git a/Week1/APLOC2 Week 1/APLOC2 Week 1/baseInsect.h b/Week1/APLOC2 Week 1/APLOC2 Week 1/baseInsect.h new file mode 100644 index 0000000..4e57be2 --- /dev/null +++ b/Week1/APLOC2 Week 1/APLOC2 Week 1/baseInsect.h @@ -0,0 +1,36 @@ +// +// baseInsect.h +// APLOC2 Week 1 +// +// Created by Brent Marohnic on 2/11/13. +// Copyright (c) 2013 Brent Marohnic. All rights reserved. +// + +#import + +@interface baseInsect : NSObject +{ + int insectEnum; +} + +typedef enum +{ + CRICKET, + BUTTERFLY, + ANT +} insectEnum; + +// data members for various insect characteristics + +@property int numberOfLegs; +@property int numberOfWings; +@property NSString *insectName; +@property int annoyanceFactor; + +// initialize +-(id)init; + +// calculate annoyance factor +-(int)calculateAnnoyanceFactor; + +@end diff --git a/Week1/APLOC2 Week 1/APLOC2 Week 1/baseInsect.m b/Week1/APLOC2 Week 1/APLOC2 Week 1/baseInsect.m new file mode 100644 index 0000000..d97541f --- /dev/null +++ b/Week1/APLOC2 Week 1/APLOC2 Week 1/baseInsect.m @@ -0,0 +1,37 @@ +// +// baseInsect.m +// APLOC2 Week 1 +// +// Created by Brent Marohnic on 2/11/13. +// Copyright (c) 2013 Brent Marohnic. All rights reserved. +// + +#import "baseInsect.h" + +@implementation baseInsect + +// allow the compiler to automatically generate get and set methods for the insect properties +@synthesize numberOfLegs, numberOfWings, insectName, annoyanceFactor; + +// initialize the base insect +-(id)init +{ + self = [super init]; + if (self != nil) + { + [self setNumberOfLegs: 0]; + [self setNumberOfWings: 0]; + [self setInsectName: nil]; + [self setAnnoyanceFactor: 0]; + } + return self; +} + +// calculate annoyance factor +-(int)calculateAnnoyanceFactor +{ + NSLog(@"Need to update insectAnnoyanceFactor to include a calculation."); + return 1; +} + +@end diff --git a/Week1/APLOC2 Week 1/APLOC2 Week 1/butterflyInsect.h b/Week1/APLOC2 Week 1/APLOC2 Week 1/butterflyInsect.h new file mode 100644 index 0000000..6bbd5e8 --- /dev/null +++ b/Week1/APLOC2 Week 1/APLOC2 Week 1/butterflyInsect.h @@ -0,0 +1,17 @@ +// +// butterflyInsect.h +// APLOC2 Week 1 +// +// Created by Brent Marohnic on 2/11/13. +// Copyright (c) 2013 Brent Marohnic. All rights reserved. +// + +#import "baseInsect.h" + +@interface butterflyInsect : baseInsect + +// insect specific data members used to calculate overall insect annoyance level +@property int soothingFlightPattern; +@property int pollinator; + +@end diff --git a/Week1/APLOC2 Week 1/APLOC2 Week 1/butterflyInsect.m b/Week1/APLOC2 Week 1/APLOC2 Week 1/butterflyInsect.m new file mode 100644 index 0000000..c362d66 --- /dev/null +++ b/Week1/APLOC2 Week 1/APLOC2 Week 1/butterflyInsect.m @@ -0,0 +1,40 @@ +// +// butterflyInsect.m +// APLOC2 Week 1 +// +// Created by Brent Marohnic on 2/11/13. +// Copyright (c) 2013 Brent Marohnic. All rights reserved. +// + +#import "butterflyInsect.h" + +@implementation butterflyInsect + +@synthesize soothingFlightPattern, pollinator; + +// set unique data members from within INIT + +-(id)init +{ + self = [super init]; + if (self != nil) + { + [self setInsectName:@"butterfly"]; + [self setSoothingFlightPattern: 0]; + [self setPollinator: 0]; + + } + return self; +} + + +// override the base insect method +-(int)calculateAnnoyanceFactor +{ + [self setAnnoyanceFactor:(soothingFlightPattern + pollinator)]; + NSLog(@"The butteryfly has an annoyance factor of %i out of 20.", self.annoyanceFactor); + return self.annoyanceFactor; +} + + +@end diff --git a/Week1/APLOC2 Week 1/APLOC2 Week 1/cricketInsect.h b/Week1/APLOC2 Week 1/APLOC2 Week 1/cricketInsect.h new file mode 100644 index 0000000..0c0fb4c --- /dev/null +++ b/Week1/APLOC2 Week 1/APLOC2 Week 1/cricketInsect.h @@ -0,0 +1,19 @@ +// +// cricketInsect.h +// APLOC2 Week 1 +// +// Created by Brent Marohnic on 2/11/13. +// Copyright (c) 2013 Brent Marohnic. All rights reserved. +// + +#import "baseInsect.h" + +@interface cricketInsect : baseInsect + +// insect specific data members used to calculate overall insect annoyance level +@property int sleepDerprivationLevel; +@property int constantChirping; +@property int nocturnal; + + +@end diff --git a/Week1/APLOC2 Week 1/APLOC2 Week 1/cricketInsect.m b/Week1/APLOC2 Week 1/APLOC2 Week 1/cricketInsect.m new file mode 100644 index 0000000..85f4c84 --- /dev/null +++ b/Week1/APLOC2 Week 1/APLOC2 Week 1/cricketInsect.m @@ -0,0 +1,41 @@ +// +// cricketInsect.m +// APLOC2 Week 1 +// +// Created by Brent Marohnic on 2/11/13. +// Copyright (c) 2013 Brent Marohnic. All rights reserved. +// + +#import "cricketInsect.h" + +@implementation cricketInsect + +@synthesize sleepDerprivationLevel, constantChirping, nocturnal; + +// set unique data members from within INIT + +-(id)init +{ + self = [super init]; + if (self != nil) + { + [self setInsectName:@"cricket"]; + [self setSleepDerprivationLevel:0]; + [self setConstantChirping: 5]; + [self setNocturnal: 5]; + + } + return self; +} + + +// override the base insect method +-(int)calculateAnnoyanceFactor +{ + [self setAnnoyanceFactor:(sleepDerprivationLevel + constantChirping + nocturnal)]; + NSLog(@"The cricket has an annoyance factor of %i out of 20.", self.annoyanceFactor); + return self.annoyanceFactor; +} + + +@end diff --git a/Week1/APLOC2 Week 1/APLOC2 Week 1/insectFactory.h b/Week1/APLOC2 Week 1/APLOC2 Week 1/insectFactory.h new file mode 100644 index 0000000..6ccf96c --- /dev/null +++ b/Week1/APLOC2 Week 1/APLOC2 Week 1/insectFactory.h @@ -0,0 +1,19 @@ +// +// insectFactory.h +// APLOC2 Week 1 +// +// Created by Brent Marohnic on 2/11/13. +// Copyright (c) 2013 Brent Marohnic. All rights reserved. +// + +#import +#import "baseInsect.h" +#import "cricketInsect.h" +#import "butterflyInsect.h" +#import "antInsect.h" + +@interface insectFactory : NSObject + ++(baseInsect *)createNewInsect:(int)insectType; + +@end diff --git a/Week1/APLOC2 Week 1/APLOC2 Week 1/insectFactory.m b/Week1/APLOC2 Week 1/APLOC2 Week 1/insectFactory.m new file mode 100644 index 0000000..6d72963 --- /dev/null +++ b/Week1/APLOC2 Week 1/APLOC2 Week 1/insectFactory.m @@ -0,0 +1,31 @@ +// +// insectFactory.m +// APLOC2 Week 1 +// +// Created by Brent Marohnic on 2/11/13. +// Copyright (c) 2013 Brent Marohnic. All rights reserved. +// + +#import "insectFactory.h" + +@implementation insectFactory + ++(baseInsect *)createNewInsect:(int)insectType +{ + if (insectType == CRICKET) + { + return [[cricketInsect alloc] init]; + } + else if (insectType == BUTTERFLY) + { + return [[butterflyInsect alloc] init]; + } + else if (insectType == ANT) + { + return [[antInsect alloc] init]; + } + else return nil; + +} + +@end