Package components.naturalnumber
Class NaturalNumber1L
java.lang.Object
components.naturalnumber.NaturalNumberSecondary
components.naturalnumber.NaturalNumber1L
- All Implemented Interfaces:
NaturalNumber,NaturalNumberKernel,Standard<NaturalNumber>,Comparable<NaturalNumber>
NaturalNumber represented as a java.math.BigInteger with implementations of primary methods.- Representation Invariant (concrete invariant of $this):
$this.rep >= 0- Abstraction Relation (interpretation mapping between $this and this):
this = $this.rep
-
Field Summary
Fields inherited from interface components.naturalnumber.NaturalNumberKernel
RADIX -
Constructor Summary
ConstructorsConstructorDescriptionNo-argument constructor.NaturalNumber1L(int i) Constructor fromint.Constructor fromNaturalNumber.Constructor fromString. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidclear()Resetsthisto an initial value.final intDividesthisby 10 and reports the remainder.final booleanisZero()Reports whetherthisis zero.final voidmultiplyBy10(int k) Multipliesthisby 10 and addsk.final NaturalNumberReturns a new object with the same dynamic type asthis, having an initial value.final voidtransferFrom(NaturalNumber source) Setsthisto the incoming value ofsource, and resetssourceto an initial value; the declaration notwithstanding, the dynamic type ofsourcemust be the same as the dynamic type ofthis.Methods inherited from class components.naturalnumber.NaturalNumberSecondary
add, canConvertToInt, canSetFromString, compareTo, copyFrom, decrement, divide, equals, hashCode, increment, multiply, power, root, setFromInt, setFromString, subtract, toInt, toString
-
Constructor Details
-
NaturalNumber1L
public NaturalNumber1L()No-argument constructor. -
NaturalNumber1L
Constructor fromint.- Parameters:
i-intto initialize from
-
NaturalNumber1L
Constructor fromString.- Parameters:
s-Stringto initialize from
-
NaturalNumber1L
Constructor fromNaturalNumber.- Parameters:
n-NaturalNumberto initialize from
-
-
Method Details
-
newInstance
Description copied from interface:StandardReturns a new object with the same dynamic type asthis, having an initial value. If the typeThas a no-argument constructor, then the value of the new returned object satisfies the contract of the no-argument constructor forT. IfTdoes not have a no-argument constructor, then the value of the new returned object satisfies the contract of the constructor call that was used to initializethis.- Returns:
- new object "like"
thiswith an initial value
-
clear
Description copied from interface:StandardResetsthisto an initial value. If the typeThas a no-argument constructor, thenthissatisfies the contract of the no-argument constructor forT. IfTdoes not have a no-argument constructor, thenthissatisfies the contract of the constructor call that was used to initialize#this. -
transferFrom
Description copied from interface:StandardSetsthisto the incoming value ofsource, and resetssourceto an initial value; the declaration notwithstanding, the dynamic type ofsourcemust be the same as the dynamic type ofthis. If the typeThas a no-argument constructor, thensourcesatisfies the contract of the no-argument constructor forT. IfTdoes not have a no-argument constructor, thensourcesatisfies the contract of the constructor call that was used to initialize#source.- Parameters:
source- object whose value is to be transferred
-
multiplyBy10
Description copied from interface:NaturalNumberKernelMultipliesthisby 10 and addsk.- Parameters:
k- theintto be added
-
divideBy10
Description copied from interface:NaturalNumberKernelDividesthisby 10 and reports the remainder.- Returns:
- the remainder
-
isZero
Description copied from interface:NaturalNumberKernelReports whetherthisis zero.- Returns:
- true iff
thisis zero
-