Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions ContaPessoas/Contador.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@
//
// Created by Vinicius Miana on 2/18/15.
// Copyright (c) 2015 Vinicius Miana. All rights reserved.
//

@interface Contador : NSObject

@interface Contador : NSObject
+(Contador *) instancia;

- (void)maisUmCueca;
- (void)maisUmaGata;

-(int)getBoys;
-(int)getGirls;
-(void) setGirls:(int) n;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Para que voce precisa de set?

-(void) setBoys:(int) n;
-(int) getTotal;

@end

@end
30 changes: 29 additions & 1 deletion ContaPessoas/Contador.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,24 @@
#import "Contador.h"


@implementation Contador {
@implementation Contador

{
int boy;
int girl;
}

static Contador *_instancia = nil;

+(Contador *) instancia
{
if (_instancia == nil) {
_instancia = [[Contador alloc] init];
}

return _instancia;
}

-(id)init {
self = [super init];
if (self) {
Expand All @@ -39,7 +52,22 @@ -(int)getGirls {
return girl;
}

-(void) setBoys:(int) n
{
boy = n;
}

-(void) setGirls:(int) n
{
girl = n;
}

-(int) getTotal
{
return boy + girl;
}

// Teste de pull request

@end

2 changes: 1 addition & 1 deletion ContaPessoas/FirstViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ @implementation FirstViewController {

- (void)viewDidLoad {
[super viewDidLoad];
contador = [[Contador alloc] init];
contador = [Contador instancia];
// Do any additional setup after loading the view, typically from a nib.
}

Expand Down
4 changes: 4 additions & 0 deletions ContaPessoas/SecondViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@

@end

// Singleton
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Para que estes comentarios aqui?

// getTotal
// teste getTotal
// Delegate
4 changes: 2 additions & 2 deletions ContaPessoas/SecondViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ @implementation SecondViewController

- (void)viewDidLoad {
[super viewDidLoad];
contador = [[Contador alloc] init];
contador = [Contador instancia];
}


Expand All @@ -32,7 +32,7 @@ - (void)didReceiveMemoryWarning {
- (IBAction)click:(id)sender {
_totalBoys.text = [NSString stringWithFormat: @"%d", [contador getBoys]];
_totalGirls.text = [NSString stringWithFormat: @"%d", [contador getGirls]];
_total.text = [NSString stringWithFormat:@"%d", [contador getGirls] + [contador getBoys] ];
_total.text = [NSString stringWithFormat:@"%d", [contador getTotal] ];
}


Expand Down