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.2.1.119 tracks/objective-c/exercises/leap/LeapExample.m
trackler-2.2.1.118 tracks/objective-c/exercises/leap/LeapExample.m
trackler-2.2.1.117 tracks/objective-c/exercises/leap/LeapExample.m
trackler-2.2.1.116 tracks/objective-c/exercises/leap/LeapExample.m
trackler-2.2.1.115 tracks/objective-c/exercises/leap/LeapExample.m
trackler-2.2.1.114 tracks/objective-c/exercises/leap/LeapExample.m
trackler-2.2.1.113 tracks/objective-c/exercises/leap/LeapExample.m
trackler-2.2.1.111 tracks/objective-c/exercises/leap/LeapExample.m
trackler-2.2.1.110 tracks/objective-c/exercises/leap/LeapExample.m
trackler-2.2.1.109 tracks/objective-c/exercises/leap/LeapExample.m
trackler-2.2.1.108 tracks/objective-c/exercises/leap/LeapExample.m
trackler-2.2.1.107 tracks/objective-c/exercises/leap/LeapExample.m
trackler-2.2.1.106 tracks/objective-c/exercises/leap/LeapExample.m
trackler-2.2.1.105 tracks/objective-c/exercises/leap/LeapExample.m
trackler-2.2.1.104 tracks/objective-c/exercises/leap/LeapExample.m
trackler-2.2.1.103 tracks/objective-c/exercises/leap/LeapExample.m
trackler-2.2.1.102 tracks/objective-c/exercises/leap/LeapExample.m
trackler-2.2.1.101 tracks/objective-c/exercises/leap/LeapExample.m
trackler-2.2.1.100 tracks/objective-c/exercises/leap/LeapExample.m
trackler-2.2.1.99 tracks/objective-c/exercises/leap/LeapExample.m