Skip to content

Instantly share code, notes, and snippets.

@gangmul12
Created March 12, 2015 02:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gangmul12/42a265281eabdd55fc92 to your computer and use it in GitHub Desktop.
Save gangmul12/42a265281eabdd55fc92 to your computer and use it in GitHub Desktop.
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class BigInteger
{
public static final String QUIT_COMMAND = "quit";
public static final String MSG_INVALID_INPUT = "입력이 잘못되었습니다.";
// implement this
public static final Pattern EXPRESSION_PATTERN = Pattern.compile("");
public BigInteger(int i)
{
}
public BigInteger(int[] num1)
{
}
public BigInteger(String s)
{
}
public BigInteger add(BigInteger big)
{
}
public BigInteger subtract(BigInteger big)
{
}
public BigInteger multiply(BigInteger big)
{
}
@Override
public String toString()
{
}
static BigInteger evaluate(String input) throws IllegalArgumentException
{
// implement here
// parse input
// using regex is allowed
// One possible implementation
// BigInteger num1 = new BigInteger(arg1);
// BigInteger num2 = new BigInteger(arg2);
// BigInteger result = num1.add(num2);
// return result;
}
public static void main(String[] args) throws Exception
{
try (InputStreamReader isr = new InputStreamReader(System.in))
{
try (BufferedReader reader = new BufferedReader(isr))
{
boolean done = false;
while (!done)
{
String input = reader.readLine();
try
{
done = processInput(input);
}
catch (IllegalArgumentException e)
{
System.err.println(MSG_INVALID_INPUT);
}
}
}
}
}
static boolean processInput(String input) throws IllegalArgumentException
{
boolean quit = isQuitCmd(input);
if (quit)
{
return true;
}
else
{
BigInteger result = evaluate(input);
System.out.println(result.toString());
return false;
}
}
static boolean isQuitCmd(String input)
{
return input.equalsIgnoreCase(QUIT_COMMAND);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment