Final Commit

This commit is contained in:
Brent Marohnic 2013-02-07 23:46:04 -05:00
parent 06ffe2b945
commit 8d1db02fb8
9 changed files with 81 additions and 2 deletions

View File

@ -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 = "<group>"; };
65DF924716C4A89C0035C5C9 /* BadChild.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BadChild.h; sourceTree = "<group>"; };
65DF924816C4A89C0035C5C9 /* BadChild.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BadChild.m; sourceTree = "<group>"; };
65DF924A16C4AE670035C5C9 /* RottenChild.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RottenChild.h; sourceTree = "<group>"; };
65DF924B16C4AE670035C5C9 /* RottenChild.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RottenChild.m; sourceTree = "<group>"; };
/* 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 = "<group>";
@ -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;
};

View File

@ -19,7 +19,7 @@ typedef enum
@interface Child : NSObject
{
@protected
@public
NSString *strName;
int intChild;
EChildType childType;

View File

@ -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];

View File

@ -21,6 +21,11 @@
{
return [[Child alloc] initWithDetails:1 inpStrName:@"Connor"];
}
else if (childType == 3)
{
return [[Child alloc] initWithDetails:3 inpStrName:@"Brent"];
}
return nil;
}

View File

@ -15,5 +15,6 @@
{
intChild = 0;
strName = @"Jack";
childType = CHILDTYPE_GOOD;
}
@end

View File

@ -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 <Foundation/Foundation.h>
#import "Child.h"
@interface RottenChild : Child
-(void)setAttributes;
@end

View File

@ -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

View File

@ -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];