/*******************************************************************
* Author: Isai Damier
* Title: LargeInteger.java
* Project: geekviewpoint
* Package: datastructure
*
* Description: Normally modern computers cannot handle very large
* numbers. So the task here is to create a datastructure that
* can handle numbers of perhaps infinite size. And to prove that
* the datastructure works, included are arithmetic operators.
*
* Naturally the numbers are represented as Strings. And to
* perform addition and subtraction, stacks are used as the media.
* Finally, as any trusty calculator, this datastructure returns
* erroneous values for erroneous inputs and correct values for
* correct inputs. This is to say, if an input string does not
* represent a valid decimal integer, then the output string
* will be bogus.
******************************************************************/
import java.util.Stack;
public class LargeInteger {
private String number;
public LargeInteger(String number) {
this.number = number;
}//constructor
public int size() {
return this.number.length();
}
}
import org.junit.Test;
import static org.junit.Assert.*;
public class LargeIntegerTest {
/**
* Test of size method, of class LargeInteger.
*/
@Test
public void testSize() {
System.out.println("size");
LargeInteger bigInteger;
String a = "8787284297498234897287345";
bigInteger = new LargeInteger(a);
assertEquals(a.length(), bigInteger.size());
}
}