mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Implementation of Linear converter
This commit is contained in:
parent
b2f4495a75
commit
7aee0a7c6a
2 changed files with 61 additions and 3 deletions
|
@ -39,7 +39,20 @@ extern "C" {
|
|||
- (double)valueFromBaseUnitValue:(double)baseUnitValue;
|
||||
@end
|
||||
|
||||
|
||||
@interface NSUnitConverterLinear : NSUnitConverter <NSCoding>
|
||||
{
|
||||
double _coefficient;
|
||||
double _constant;
|
||||
}
|
||||
|
||||
- (instancetype) initWithCoefficient: (double)coefficient;
|
||||
- (instancetype) initWithCoefficient: (double)coefficient
|
||||
constant: (double)constant;
|
||||
|
||||
- (double) coefficient;
|
||||
- (double) constant;
|
||||
@end
|
||||
|
||||
@interface NSUnit : NSObject <NSCopying, NSCoding>
|
||||
{
|
||||
NSString *_symbol;
|
||||
|
|
|
@ -38,8 +38,54 @@
|
|||
}
|
||||
@end
|
||||
|
||||
|
||||
@implementation NSUnitConverterLinear
|
||||
|
||||
- (instancetype) initWithCoefficient: (double)coefficient
|
||||
{
|
||||
self = [super init];
|
||||
if(self != nil)
|
||||
{
|
||||
_coefficient = coefficient;
|
||||
_constant = 0.0;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype) initWithCoefficient: (double)coefficient
|
||||
constant: (double)constant
|
||||
{
|
||||
self = [super init];
|
||||
if(self != nil)
|
||||
{
|
||||
_coefficient = coefficient;
|
||||
_constant = constant;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) initWithCoder: (NSCoder *)coder
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void) encodeWithCoder: (NSCoder *)coder
|
||||
{
|
||||
}
|
||||
|
||||
- (double) coefficient
|
||||
{
|
||||
return _coefficient;
|
||||
}
|
||||
|
||||
- (double) constant
|
||||
{
|
||||
return _constant;
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
@implementation NSUnit
|
||||
|
||||
+ (instancetype)new
|
||||
{
|
||||
return [[self alloc] init];
|
||||
|
@ -100,6 +146,5 @@
|
|||
{
|
||||
return _symbol;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
|
Loading…
Reference in a new issue