use crate::common::Result;
use crate::Exceptions;
use super::DecodedObject;
pub struct DecodedNumeric {
newPosition: usize,
firstDigit: u32,
secondDigit: u32,
}
impl DecodedObject for DecodedNumeric {
fn getNewPosition(&self) -> usize {
self.newPosition
}
}
impl DecodedNumeric {
pub const FNC1: u32 = 10;
pub fn new(newPosition: usize, firstDigit: u32, secondDigit: u32) -> Result<Self> {
if
firstDigit > 10 || secondDigit > 10 {
return Err(Exceptions::FORMAT);
}
Ok(Self {
newPosition,
firstDigit,
secondDigit,
})
}
pub fn getFirstDigit(&self) -> u32 {
self.firstDigit
}
pub fn getSecondDigit(&self) -> u32 {
self.secondDigit
}
pub fn getValue(&self) -> u32 {
self.firstDigit * 10 + self.secondDigit
}
pub fn isFirstDigitFNC1(&self) -> bool {
self.firstDigit == Self::FNC1
}
pub fn isSecondDigitFNC1(&self) -> bool {
self.secondDigit == Self::FNC1
}
}