/*
VIDEH SEKSARIA -
ROCKY RUN MIDDLE SCHOOL
ACSL CO0NTEST
NUMBER THREE
3/4/5011
TASKS: ACSL
MANCALA JUNIOR
LANG: JAVA
*/
import java.io.*;
import java.util.*;
import javax.swing.*;
import java.awt.*;
public class SeksariaVContest3
{
static Map <String, Integer> BOARD
= new HashMap <String, Integer>();
static int numInput = 0;
static String finalOut = "";
public static void main(String[] args)
throws Exception
{
JDialog.setDefaultLookAndFeelDecorated(true);
fill();
while(true)
{
numInput++;
int response =
JOptionPane.showConfirmDialog(null, "Is There [More] Input?",
"Confirm",
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if (response ==
JOptionPane.NO_OPTION)
{
System.out.println("Thank
You");
JOptionPane.showMessageDialog(null, finalOut);
System.exit(0);
break;
}
else if (response ==
JOptionPane.CLOSED_OPTION)
{
System.out.println("Thank
You");
System.exit(0);
break;
}
else if (response == JOptionPane.YES_OPTION)
{
String input =
JOptionPane.showInputDialog("Enter Input:");
play(input);
JOptionPane.showMessageDialog(null, finalOut);
}
if(numInput == 5)
{
fill();
finalOut = "";
}
}
}
static void fill()
{
BOARD.put(new String("1"),
4);
BOARD.put(new String("2"),
4);
BOARD.put(new String("3"),
4);
BOARD.put(new String("4"),
4);
BOARD.put(new String("5"),
4);
BOARD.put(new String("6"),
4);
BOARD.put(new String("A"),
0);
BOARD.put(new String("7"),
4);
BOARD.put(new String("8"),
4);
BOARD.put(new String("9"), 4);
BOARD.put(new String("10"),
4);
BOARD.put(new String("11"),
4);
BOARD.put(new String("12"),
4);
BOARD.put(new String("B"),
0);
}
static void play(String IN)
{
int x = 0;
String start = "";
String get = "";
String current = IN.substring(x, x +
1);
while(true)
{
if(type1(current))
{
start += current;
x++;
current = IN.substring(x, x +
1);
}
else
break;
}
while(true)
{
if(type2(current))
{
x++;
current = IN.substring(x, x +
1);
}
else
break;
}
while(type1(current))
{
if(type1(current))
{
get += current;
x++;
if(x == IN.length())
break;
current = IN.substring(x, x +
1);
}
else
break;
}
int location =
Integer.parseInt(start);
int location2;
if(location <= 6)
location2 = 1;
else
location2 = 2;
int numStart = BOARD.get(start);
int prev;
BOARD.put(new String (start), 0);
int z = 1;
for(int y = 1; y <= numStart; y++)
{
if(z == numStart)
break;
location += z;
if(location > 12)
{
if( (location == 12) &&
(location2 == 2) )
{
prev =
BOARD.get("B");
BOARD.put(new
String("B"), prev+1);
y++;
}
else
location = location - 12;
}
String spot =
Integer.toString(location);
prev = BOARD.get(spot);
BOARD.put(new String(spot),
prev+1);
if( (location == 6) &&
(location2 == 1) )
{
prev = BOARD.get("A");
BOARD.put(new
String("A"), prev+1);
y++;
}
z++;
location = Integer.parseInt(start);
}
System.out.println(numInput + ".
" + BOARD.get(get));
finalOut += numInput + ". "
+ BOARD.get(get) + "\n";
}
static boolean type2(String in)
{
if(in.equals(" "))
return true;
if(in.equals(","))
return true;
else
return false;
}
static boolean type1(String in)
{
if(in.equals("0"))
return true;
else if(in.equals("1"))
return true;
else if(in.equals("2"))
return true;
else if(in.equals("3"))
return true;
else if(in.equals("4"))
return true;
else if(in.equals("5"))
return true;
else if(in.equals("6"))
return true;
else if(in.equals("7"))
return true;
else if(in.equals("8"))
return true;
else if(in.equals("9"))
return true;
else if(in.equals("A"))
return true;
else if(in.equals("B"))
return true;
else
return false;
}
}