Sha256: 82c66c9dad325abeea195b852ca9c7d662decb277008fb19e8620882fcd24ac4

Contents?: true

Size: 682 Bytes

Versions: 33

Compression:

Stored size: 682 Bytes

Contents

#import "TriangleExample.h"

@implementation Triangle

+ (TriangleKind)kindForSides:(double)a :(double)b :(double)c {
    if (a <= 0 || b <= 0 || c <= 0) {
        @throw [NSException exceptionWithName:@"Invalid triangle" reason:@"All lengths must be positive" userInfo:nil];
    } else if (a + b <= c || b + c <= a || a + c <= b) {
        @throw [NSException exceptionWithName:@"Invalid triangle" reason:@"Violation of triangle inequality" userInfo:nil];
    }
    
    if (a == b && b == c) {
        return TriangleKindEquilateral;
    } else if (a == b || b == c || a == c) {
        return TriangleKindIsosceles;
    } else {
        return TriangleKindScalene;
    }
}

@end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
trackler-2.0.3.7 tracks/objective-c/exercises/triangle/TriangleExample.m
trackler-2.0.3.6 tracks/objective-c/exercises/triangle/TriangleExample.m
trackler-2.0.3.5 tracks/objective-c/exercises/triangle/TriangleExample.m
trackler-2.0.3.4 tracks/objective-c/exercises/triangle/TriangleExample.m
trackler-2.0.3.3 tracks/objective-c/exercises/triangle/TriangleExample.m
trackler-2.0.3.2 tracks/objective-c/exercises/triangle/TriangleExample.m
trackler-2.0.3.1 tracks/objective-c/exercises/triangle/TriangleExample.m
trackler-2.0.3.0 tracks/objective-c/exercises/triangle/TriangleExample.m
trackler-2.0.2.0 tracks/objective-c/exercises/triangle/TriangleExample.m
trackler-2.0.1.2 tracks/objective-c/exercises/triangle/TriangleExample.m
trackler-2.0.1.1 tracks/objective-c/exercises/triangle/TriangleExample.m
trackler-2.0.1.0 tracks/objective-c/exercises/triangle/TriangleExample.m
trackler-2.0.0.10 tracks/objective-c/exercises/triangle/TriangleExample.m
trackler-2.0.0.9 tracks/objective-c/exercises/triangle/TriangleExample.m
trackler-2.0.0.8 tracks/objective-c/exercises/triangle/TriangleExample.m
trackler-2.0.0.7 tracks/objective-c/exercises/triangle/TriangleExample.m
trackler-2.0.0.6 tracks/objective-c/exercises/triangle/TriangleExample.m
trackler-2.0.0.5 tracks/objective-c/exercises/triangle/TriangleExample.m
trackler-2.0.0.4 tracks/objective-c/exercises/triangle/TriangleExample.m
trackler-2.0.0.3 tracks/objective-c/exercises/triangle/TriangleExample.m