Getting Closer

This commit is contained in:
Brent Marohnic 2013-02-07 22:52:03 -05:00
parent 14cdba042f
commit 06ffe2b945
12 changed files with 203 additions and 11 deletions

View File

@ -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 = "<group>"; };
65DF923B16C3B2CB0035C5C9 /* Child.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Child.h; sourceTree = "<group>"; };
65DF923C16C3B2CB0035C5C9 /* Child.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Child.m; sourceTree = "<group>"; };
65DF923E16C479840035C5C9 /* ChildFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChildFactory.h; sourceTree = "<group>"; };
65DF923F16C479840035C5C9 /* ChildFactory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChildFactory.m; sourceTree = "<group>"; };
65DF924116C49D240035C5C9 /* GoodChild.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GoodChild.h; sourceTree = "<group>"; };
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>"; };
/* 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 = "<group>";
@ -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;
};

View File

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

View File

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

View File

@ -8,14 +8,27 @@
#import <Foundation/Foundation.h>
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;

View File

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

View File

@ -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 <Foundation/Foundation.h>
#import "Child.h"
@interface ChildFactory : NSObject
-(Child*)GetChild:(int)childType;
@end

View File

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

View File

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

View File

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

View File

@ -12,5 +12,10 @@
@interface ViewController : UIViewController
{
UILabel *firstLabel;
UILabel *secondLabel;
UILabel *thirdLabel;
UILabel *fourthLabel;
UILabel *fifthLabel;
UILabel *sixthLabel;
}
@end

View File

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