diff --git a/Contador/.gitignore b/Contador/.gitignore new file mode 100644 index 0000000..6e13704 --- /dev/null +++ b/Contador/.gitignore @@ -0,0 +1,21 @@ +# Xcode +.DS_Store +*/build/* +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata +profile +*.moved-aside +DerivedData +.idea/ +*.hmap +*.xccheckout + +#CocoaPods +Pods diff --git a/ContaPessoas.xcodeproj/project.pbxproj b/Contador/ContaPessoas.xcodeproj/project.pbxproj similarity index 99% rename from ContaPessoas.xcodeproj/project.pbxproj rename to Contador/ContaPessoas.xcodeproj/project.pbxproj index 9ce30d1..ca06d09 100644 --- a/ContaPessoas.xcodeproj/project.pbxproj +++ b/Contador/ContaPessoas.xcodeproj/project.pbxproj @@ -438,6 +438,7 @@ 27A199C81A94B2A8008DC684 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; 27A199C91A94B2A8008DC684 /* Build configuration list for PBXNativeTarget "ContaPessoasTests" */ = { isa = XCConfigurationList; @@ -446,6 +447,7 @@ 27A199CB1A94B2A8008DC684 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; diff --git a/ContaPessoas.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Contador/ContaPessoas.xcodeproj/project.xcworkspace/contents.xcworkspacedata similarity index 100% rename from ContaPessoas.xcodeproj/project.xcworkspace/contents.xcworkspacedata rename to Contador/ContaPessoas.xcodeproj/project.xcworkspace/contents.xcworkspacedata diff --git a/ContaPessoas/AppDelegate.h b/Contador/ContaPessoas/AppDelegate.h similarity index 100% rename from ContaPessoas/AppDelegate.h rename to Contador/ContaPessoas/AppDelegate.h diff --git a/ContaPessoas/AppDelegate.m b/Contador/ContaPessoas/AppDelegate.m similarity index 100% rename from ContaPessoas/AppDelegate.m rename to Contador/ContaPessoas/AppDelegate.m diff --git a/ContaPessoas/Base.lproj/LaunchScreen.xib b/Contador/ContaPessoas/Base.lproj/LaunchScreen.xib similarity index 100% rename from ContaPessoas/Base.lproj/LaunchScreen.xib rename to Contador/ContaPessoas/Base.lproj/LaunchScreen.xib diff --git a/ContaPessoas/Base.lproj/Main.storyboard b/Contador/ContaPessoas/Base.lproj/Main.storyboard similarity index 82% rename from ContaPessoas/Base.lproj/Main.storyboard rename to Contador/ContaPessoas/Base.lproj/Main.storyboard index 99fa0dc..c282e08 100644 --- a/ContaPessoas/Base.lproj/Main.storyboard +++ b/Contador/ContaPessoas/Base.lproj/Main.storyboard @@ -2,6 +2,7 @@ + @@ -13,21 +14,25 @@ - + - diff --git a/ContaPessoas/Contador.h b/Contador/ContaPessoas/Contador.h similarity index 50% rename from ContaPessoas/Contador.h rename to Contador/ContaPessoas/Contador.h index 18b7c16..b40dfd5 100644 --- a/ContaPessoas/Contador.h +++ b/Contador/ContaPessoas/Contador.h @@ -3,16 +3,23 @@ // ContaPessoas // // Created by Vinicius Miana on 2/18/15. -// Copyright (c) 2015 Vinicius Miana. All rights reserved. +// Copyright (c) 2015 Vinicius Viana. All rights reserved. // +@protocol deleg +-(void)atualizar; + +@end @interface Contador : NSObject +@property (nonatomic,weak)id mostrar; ++(instancetype)getInstance; - (void)maisUmCueca; - (void)maisUmaGata; -(int)getBoys; -(int)getGirls; +-(int)getTotal; @end diff --git a/ContaPessoas/Contador.m b/Contador/ContaPessoas/Contador.m similarity index 67% rename from ContaPessoas/Contador.m rename to Contador/ContaPessoas/Contador.m index fa64ad8..bec9a59 100644 --- a/ContaPessoas/Contador.m +++ b/Contador/ContaPessoas/Contador.m @@ -23,12 +23,23 @@ -(id)init { } return self; } ++(instancetype)getInstance{ + static Contador *instance=nil; + + if (instance==nil) { + instance = [[Contador alloc] init]; + } + + return instance; +} - (void)maisUmCueca { boy = boy + 1; + [_mostrar atualizar]; } - (void)maisUmaGata { girl++; + [_mostrar atualizar]; } -(int)getBoys { @@ -38,6 +49,9 @@ -(int)getBoys { -(int)getGirls { return girl; } +-(int)getTotal{ + return boy+girl; +} diff --git a/ContaPessoas/FirstViewController.h b/Contador/ContaPessoas/FirstViewController.h similarity index 100% rename from ContaPessoas/FirstViewController.h rename to Contador/ContaPessoas/FirstViewController.h diff --git a/ContaPessoas/FirstViewController.m b/Contador/ContaPessoas/FirstViewController.m similarity index 85% rename from ContaPessoas/FirstViewController.m rename to Contador/ContaPessoas/FirstViewController.m index fc70dd5..584a606 100644 --- a/ContaPessoas/FirstViewController.m +++ b/Contador/ContaPessoas/FirstViewController.m @@ -19,8 +19,9 @@ @implementation FirstViewController { - (void)viewDidLoad { [super viewDidLoad]; - contador = [[Contador alloc] init]; - // Do any additional setup after loading the view, typically from a nib. + contador = [Contador getInstance]; + // adicionando linhas comentadas... +// NSLog(@"resultado esperado é ..."); } - (void)didReceiveMemoryWarning { diff --git a/ContaPessoas/FirstViewController.xib b/Contador/ContaPessoas/FirstViewController.xib similarity index 100% rename from ContaPessoas/FirstViewController.xib rename to Contador/ContaPessoas/FirstViewController.xib diff --git a/ContaPessoas/Images.xcassets/AppIcon.appiconset/Contents.json b/Contador/ContaPessoas/Images.xcassets/AppIcon.appiconset/Contents.json similarity index 100% rename from ContaPessoas/Images.xcassets/AppIcon.appiconset/Contents.json rename to Contador/ContaPessoas/Images.xcassets/AppIcon.appiconset/Contents.json diff --git a/ContaPessoas/Images.xcassets/first.imageset/Contents.json b/Contador/ContaPessoas/Images.xcassets/first.imageset/Contents.json similarity index 100% rename from ContaPessoas/Images.xcassets/first.imageset/Contents.json rename to Contador/ContaPessoas/Images.xcassets/first.imageset/Contents.json diff --git a/ContaPessoas/Images.xcassets/first.imageset/first.pdf b/Contador/ContaPessoas/Images.xcassets/first.imageset/first.pdf similarity index 100% rename from ContaPessoas/Images.xcassets/first.imageset/first.pdf rename to Contador/ContaPessoas/Images.xcassets/first.imageset/first.pdf diff --git a/ContaPessoas/Images.xcassets/second.imageset/Contents.json b/Contador/ContaPessoas/Images.xcassets/second.imageset/Contents.json similarity index 100% rename from ContaPessoas/Images.xcassets/second.imageset/Contents.json rename to Contador/ContaPessoas/Images.xcassets/second.imageset/Contents.json diff --git a/ContaPessoas/Images.xcassets/second.imageset/second.pdf b/Contador/ContaPessoas/Images.xcassets/second.imageset/second.pdf similarity index 100% rename from ContaPessoas/Images.xcassets/second.imageset/second.pdf rename to Contador/ContaPessoas/Images.xcassets/second.imageset/second.pdf diff --git a/ContaPessoas/Info.plist b/Contador/ContaPessoas/Info.plist similarity index 100% rename from ContaPessoas/Info.plist rename to Contador/ContaPessoas/Info.plist diff --git a/ContaPessoas/SecondViewController.h b/Contador/ContaPessoas/SecondViewController.h similarity index 83% rename from ContaPessoas/SecondViewController.h rename to Contador/ContaPessoas/SecondViewController.h index f907831..14e6f20 100644 --- a/ContaPessoas/SecondViewController.h +++ b/Contador/ContaPessoas/SecondViewController.h @@ -7,8 +7,9 @@ // #import +#import "Contador.h" -@interface SecondViewController : UIViewController +@interface SecondViewController : UIViewController @property (weak, nonatomic) IBOutlet UILabel *totalBoys; @property (weak, nonatomic) IBOutlet UILabel *totalGirls; diff --git a/ContaPessoas/SecondViewController.m b/Contador/ContaPessoas/SecondViewController.m similarity index 68% rename from ContaPessoas/SecondViewController.m rename to Contador/ContaPessoas/SecondViewController.m index a2a66f5..f595e0e 100644 --- a/ContaPessoas/SecondViewController.m +++ b/Contador/ContaPessoas/SecondViewController.m @@ -9,6 +9,7 @@ #import "SecondViewController.h" #import "Contador.h" + @interface SecondViewController () { Contador *contador; } @@ -17,9 +18,16 @@ @interface SecondViewController () { @implementation SecondViewController +-(void) atualizar{ + _totalBoys.text = [NSString stringWithFormat: @"%d", [contador getBoys]]; + _totalGirls.text = [NSString stringWithFormat: @"%d", [contador getGirls]]; + _total.text = [NSString stringWithFormat:@"%d", [contador getTotal]]; +} - (void)viewDidLoad { [super viewDidLoad]; - contador = [[Contador alloc] init]; + contador = [Contador getInstance]; + contador.mostrar=self; + [self atualizar]; } @@ -32,7 +40,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]]; } diff --git a/ContaPessoas/boy.png b/Contador/ContaPessoas/boy.png similarity index 100% rename from ContaPessoas/boy.png rename to Contador/ContaPessoas/boy.png diff --git a/ContaPessoas/girl.png b/Contador/ContaPessoas/girl.png similarity index 100% rename from ContaPessoas/girl.png rename to Contador/ContaPessoas/girl.png diff --git a/ContaPessoas/main.m b/Contador/ContaPessoas/main.m similarity index 100% rename from ContaPessoas/main.m rename to Contador/ContaPessoas/main.m diff --git a/ContaPessoasTests/ContaPessoasTests.m b/Contador/ContaPessoasTests/ContaPessoasTests.m similarity index 62% rename from ContaPessoasTests/ContaPessoasTests.m rename to Contador/ContaPessoasTests/ContaPessoasTests.m index 579bb3f..a995d1c 100644 --- a/ContaPessoasTests/ContaPessoasTests.m +++ b/Contador/ContaPessoasTests/ContaPessoasTests.m @@ -21,6 +21,8 @@ - (void)testContaMeninos { Contador *c = [[Contador alloc] init]; [c maisUmCueca]; XCTAssert(([c getBoys] == 1), @"Pass"); + XCTAssert(([c getGirls] == 0), @"Pass"); + XCTAssert(([c getTotal] == 1), @"Pass"); } - (void)testContaMeninas { @@ -28,6 +30,15 @@ - (void)testContaMeninas { [c maisUmaGata]; XCTAssert(([c getGirls] == 1), @"Pass"); XCTAssert(([c getBoys] == 0), @"Pass"); + XCTAssert(([c getTotal] == 1), @"Pass"); +} +-(void)testContaTotal { + Contador *c = [[Contador alloc] init]; + [c maisUmaGata]; + [c maisUmCueca]; + XCTAssert(([c getGirls] == 1), @"Pass"); + XCTAssert(([c getBoys] == 1), @"Pass"); + XCTAssert(([c getTotal] == 2), @"Pass"); } diff --git a/ContaPessoasTests/ContadorTests.m b/Contador/ContaPessoasTests/ContadorTests.m similarity index 100% rename from ContaPessoasTests/ContadorTests.m rename to Contador/ContaPessoasTests/ContadorTests.m diff --git a/ContaPessoasTests/Info.plist b/Contador/ContaPessoasTests/Info.plist similarity index 100% rename from ContaPessoasTests/Info.plist rename to Contador/ContaPessoasTests/Info.plist diff --git a/Contador/MySingleton.h b/Contador/MySingleton.h new file mode 100644 index 0000000..7728fd6 --- /dev/null +++ b/Contador/MySingleton.h @@ -0,0 +1,15 @@ +// +// MySingleton.h +// ContaPessoas +// +// Created by Humberto Julião on 19/02/15. +// Copyright (c) 2015 Vinicius Miana. All rights reserved. +// + +#import + +@interface MySingleton : NSObject ++(MySingleton *) sharedInstance; + +@end + diff --git a/Contador/MySingleton.m b/Contador/MySingleton.m new file mode 100644 index 0000000..12c2d96 --- /dev/null +++ b/Contador/MySingleton.m @@ -0,0 +1,19 @@ +// +// MySingleton.m +// ContaPessoas +// +// Created by Humberto Julião on 19/02/15. +// Copyright (c) 2015 Vinicius Miana. All rights reserved. +// + +#import "MySingleton.h" + +@implementation MySingleton ++ (MySingleton *)sharedInstance{ + static MySingleton * sharedMyManager = nil ; + static dispatch_once_t token ; + dispatch_once ( & token , ^ { sharedMyManager = [[ self alloc ] init ]; }); + return sharedMyManager ; +} + +@end diff --git a/Contador/README.md b/Contador/README.md new file mode 100644 index 0000000..5e4eee8 --- /dev/null +++ b/Contador/README.md @@ -0,0 +1,11 @@ +# Contador + +## Padrões de Projetos + +### Tema: Engenharia de Software + +### Questão essencial: Como facilitar a reutilização de soluções empregadas no projeto de um software e trabalhar de maneira colaborativa? + + +### Desafio: Melhorar o projeto do aplicativo conta pessoas +