Sha256: eec60a572f2ae6e28f7d7f4f262927c4d9b66945dc1ed464af6fb8bdd0ef3698

Contents?: true

Size: 874 Bytes

Versions: 396

Compression:

Stored size: 874 Bytes

Contents

#import <Foundation/Foundation.h>
#import "LeapExample.h"

@interface Leap ()

@property (nonatomic,strong,readwrite) NSNumber *value;

@end

@implementation Leap

- (instancetype)initWithCalendarYear:(NSNumber *)calendarYear {
  self = [super init];
  if (self) {
    self.value = calendarYear;
  }
  return self;
}

- (BOOL)isLeapYear {
  return ([self divisibleByFour] && ![self divisibleByHundred]) || [self divisibleByFourHundred];
}

- (int)intValue {
  return (int)[[self value] integerValue];
}

- (BOOL)divisibleByFour {
  return [self is:[self intValue] evenlyDivisibleBy:4];
}

- (BOOL)divisibleByHundred {
  return [self is:[self intValue] evenlyDivisibleBy:100];
}

- (BOOL)divisibleByFourHundred {
  return [self is:[self intValue] evenlyDivisibleBy:400];
}

- (BOOL)is:(int)numerator evenlyDivisibleBy:(int)divisor {
  return numerator % divisor == 0;
}

@end

Version data entries

396 entries across 396 versions & 1 rubygems

Version Path
trackler-2.0.6.20 tracks/objective-c/exercises/leap/LeapExample.m
trackler-2.0.6.19 tracks/objective-c/exercises/leap/LeapExample.m
trackler-2.0.6.18 tracks/objective-c/exercises/leap/LeapExample.m
trackler-2.0.6.17 tracks/objective-c/exercises/leap/LeapExample.m
trackler-2.0.6.16 tracks/objective-c/exercises/leap/LeapExample.m
trackler-2.0.6.15 tracks/objective-c/exercises/leap/LeapExample.m
trackler-2.0.6.14 tracks/objective-c/exercises/leap/LeapExample.m
trackler-2.0.6.13 tracks/objective-c/exercises/leap/LeapExample.m
trackler-2.0.6.12 tracks/objective-c/exercises/leap/LeapExample.m
trackler-2.0.6.11 tracks/objective-c/exercises/leap/LeapExample.m
trackler-2.0.6.10 tracks/objective-c/exercises/leap/LeapExample.m
trackler-2.0.6.9 tracks/objective-c/exercises/leap/LeapExample.m
trackler-2.0.6.8 tracks/objective-c/exercises/leap/LeapExample.m
trackler-2.0.6.7 tracks/objective-c/exercises/leap/LeapExample.m
trackler-2.0.6.6 tracks/objective-c/exercises/leap/LeapExample.m
trackler-2.0.6.5 tracks/objective-c/exercises/leap/LeapExample.m
trackler-2.0.6.4 tracks/objective-c/exercises/leap/LeapExample.m
trackler-2.0.6.3 tracks/objective-c/exercises/leap/LeapExample.m
trackler-2.0.6.2 tracks/objective-c/exercises/leap/LeapExample.m
trackler-2.0.6.1 tracks/objective-c/exercises/leap/LeapExample.m