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
21 changes: 21 additions & 0 deletions Contador/.gitignore
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@
27A199C81A94B2A8008DC684 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
27A199C91A94B2A8008DC684 /* Build configuration list for PBXNativeTarget "ContaPessoasTests" */ = {
isa = XCConfigurationList;
Expand All @@ -446,6 +447,7 @@
27A199CB1A94B2A8008DC684 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6254" systemVersion="14C109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="49e-Tb-3d3">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
</dependencies>
<scenes>
<!--First-->
Expand All @@ -13,21 +14,25 @@
<viewControllerLayoutGuide type="bottom" id="4ug-Mw-9AY"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="tsR-hK-woN">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" misplaced="YES" text="Contador" textAlignment="center" lineBreakMode="tailTruncation" minimumFontSize="10" translatesAutoresizingMaskIntoConstraints="NO" id="KQZ-1w-vlD">
<rect key="frame" x="222" y="25" width="157.5" height="41.5"/>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" text="Contador" textAlignment="center" lineBreakMode="tailTruncation" minimumFontSize="10" translatesAutoresizingMaskIntoConstraints="NO" id="KQZ-1w-vlD">
<rect key="frame" x="82" y="31" width="157.5" height="41.5"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="width" constant="157.5" id="Hfv-WE-6ga"/>
<constraint firstAttribute="height" constant="41.5" id="paz-Nf-dQU"/>
</constraints>
<fontDescription key="fontDescription" name="Helvetica" family="Helvetica" pointSize="36"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="hYm-mB-gId">
<rect key="frame" x="167" y="75" width="128" height="224"/>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="hYm-mB-gId">
<rect key="frame" x="26" y="172" width="128" height="224"/>
<constraints>
<constraint firstAttribute="height" constant="300" id="GJ8-PI-wpB"/>
<constraint firstAttribute="width" constant="150" id="wRK-D8-fAn"/>
<constraint firstAttribute="width" constant="128" id="1rP-Lg-Rc6"/>
<constraint firstAttribute="height" constant="224" id="fuX-uf-mbJ"/>
</constraints>
<state key="normal" image="boy.png">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
Expand All @@ -36,11 +41,11 @@
<action selector="clickBoy:" destination="9pv-A4-QxB" eventType="touchDown" id="QWF-hu-z2B"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="jQx-1Z-n65">
<rect key="frame" x="298" y="81" width="111" height="211"/>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="jQx-1Z-n65">
<rect key="frame" x="182" y="172" width="111" height="224"/>
<constraints>
<constraint firstAttribute="width" constant="300" id="D13-p5-bzh"/>
<constraint firstAttribute="height" constant="150" id="Q06-7B-no7"/>
<constraint firstAttribute="width" constant="111" id="8nd-NI-KXt"/>
<constraint firstAttribute="height" constant="224" id="W4Q-7k-GWX"/>
</constraints>
<state key="normal" title="Button" image="girl.png">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
Expand All @@ -52,22 +57,20 @@
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="centerY" secondItem="hYm-mB-gId" secondAttribute="centerY" constant="113" id="25f-oe-XWF"/>
<constraint firstAttribute="centerX" secondItem="KQZ-1w-vlD" secondAttribute="centerX" id="6BV-lF-sBN"/>
<constraint firstAttribute="centerY" secondItem="KQZ-1w-vlD" secondAttribute="centerY" constant="254.25" id="7NO-DY-fvY"/>
<constraint firstAttribute="centerX" secondItem="hYm-mB-gId" secondAttribute="centerX" constant="105" id="BIr-Ng-iZd"/>
<constraint firstAttribute="centerX" secondItem="jQx-1Z-n65" secondAttribute="centerX" constant="-53.5" id="HvV-q8-w7n"/>
<constraint firstItem="jQx-1Z-n65" firstAttribute="width" secondItem="hYm-mB-gId" secondAttribute="width" id="QXq-FV-L3B"/>
<constraint firstItem="jQx-1Z-n65" firstAttribute="top" secondItem="hYm-mB-gId" secondAttribute="top" constant="31" id="Sxc-Z0-BuJ"/>
<constraint firstItem="jQx-1Z-n65" firstAttribute="height" secondItem="hYm-mB-gId" secondAttribute="height" id="eqk-7z-cvb"/>
<constraint firstAttribute="top" secondItem="KQZ-1w-vlD" secondAttribute="top" id="exm-UA-ej4"/>
<constraint firstAttribute="centerY" secondItem="hYm-mB-gId" secondAttribute="centerY" id="1C6-wr-0yr"/>
<constraint firstItem="hYm-mB-gId" firstAttribute="leading" secondItem="tsR-hK-woN" secondAttribute="leadingMargin" constant="10" id="4To-HR-wsT"/>
<constraint firstAttribute="centerY" secondItem="jQx-1Z-n65" secondAttribute="centerY" id="6W1-yr-Gom"/>
<constraint firstAttribute="centerX" secondItem="KQZ-1w-vlD" secondAttribute="centerX" id="PCR-Eq-8ay"/>
<constraint firstItem="KQZ-1w-vlD" firstAttribute="top" secondItem="Ia1-K6-d13" secondAttribute="bottom" constant="11" id="xpP-97-OZT"/>
<constraint firstAttribute="trailingMargin" secondItem="jQx-1Z-n65" secondAttribute="trailing" constant="11" id="ytc-Ar-FLA"/>
</constraints>
</view>
<tabBarItem key="tabBarItem" title="First" image="first" id="acW-dT-cKf"/>
<simulatedScreenMetrics key="simulatedDestinationMetrics" type="retina4"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="W5J-7L-Pyd" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="750" y="-320"/>
<point key="canvasLocation" x="804" y="-326"/>
</scene>
<!--Second-->
<scene sceneID="wg7-f3-ORb">
Expand Down Expand Up @@ -123,15 +126,6 @@
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Wdw-cL-Bgf">
<rect key="frame" x="299" y="406" width="54" height="30"/>
<state key="normal" title="Atualiza">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="click:" destination="8rJ-Kc-sve" eventType="touchUpInside" id="Wmf-Ss-Ora"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
Expand Down
9 changes: 8 additions & 1 deletion ContaPessoas/Contador.h → Contador/ContaPessoas/Contador.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <NSObject>

-(void)atualizar;

@end
@interface Contador : NSObject

@property (nonatomic,weak)id mostrar;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Use id para dizer que não é um objeto qualquer.

+(instancetype)getInstance;
- (void)maisUmCueca;
- (void)maisUmaGata;

-(int)getBoys;
-(int)getGirls;
-(int)getTotal;

@end

14 changes: 14 additions & 0 deletions ContaPessoas/Contador.m → Contador/ContaPessoas/Contador.m
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -38,6 +49,9 @@ -(int)getBoys {
-(int)getGirls {
return girl;
}
-(int)getTotal{
return boy+girl;
}



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
//

#import <UIKit/UIKit.h>
#import "Contador.h"

@interface SecondViewController : UIViewController
@interface SecondViewController : UIViewController<deleg>

@property (weak, nonatomic) IBOutlet UILabel *totalBoys;
@property (weak, nonatomic) IBOutlet UILabel *totalGirls;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#import "SecondViewController.h"
#import "Contador.h"


@interface SecondViewController () {
Contador *contador;
}
Expand All @@ -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];
}


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


Expand Down
File renamed without changes
File renamed without changes
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,24 @@ - (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 {
Contador *c = [[Contador alloc] init];
[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");
}


Expand Down
File renamed without changes.
15 changes: 15 additions & 0 deletions Contador/MySingleton.h
Original file line number Diff line number Diff line change
@@ -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 <Foundation/Foundation.h>

@interface MySingleton : NSObject
+(MySingleton *) sharedInstance;

@end

19 changes: 19 additions & 0 deletions Contador/MySingleton.m
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions Contador/README.md
Original file line number Diff line number Diff line change
@@ -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