// Kevin Dawe's Java Liberry
// This file must be in the same folderas the file using it
// int x = MyLib.getInt();

import java.io.*;
import java.util.*;
 import javax.swing.*;  
import java.awt.*;
import java.awt.image.*;
import java.awt.event.*;
class MyLib
{
	private	static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	private static Random ran= new Random();
	public static int getInt()
	{
		String input=new String();
		int inputInt=0;
		try
		{
			input=br.readLine();
		}
		catch (IOException e)
		{
			System.out.println("IO Error: " +e);
			System.out.print("Please re-enter input: ");
			return(getInt());
		}
		try
		{
			inputInt=Integer.parseInt(input);
		}
		catch (NumberFormatException e)
		{
			System.out.println("Non Integer Input Error: " +e);
			System.out.print("Please re-enter input: ");
			return(getInt());
		}	
		return(inputInt);	
	}
	
	public static String getStr()
	{
		String input=new String();
		try
		{
			input=br.readLine();
		}
		catch (IOException e)
		{
			System.out.println("IO Error: " +e);
			System.out.print("Please re-enter input: ");
			return(getStr());
		}
		return(input);	
	}
	
	public static double getDbl()
	{
		String input=new String();
		double inputDbl=0;
		try
		{
			input=br.readLine();
		}
		catch (IOException e)
		{
			System.out.println("IO Error: " +e);
			System.out.print("Please re-enter input: ");
			return(getDbl());
		}
		try
		{
			inputDbl=Double.parseDouble(input);
		}
		catch (NumberFormatException e)
		{
			System.out.println("Non Double Input Error: " +e);
			System.out.print("Please re-enter input: ");
			return(getDbl());
		}	
		return(inputDbl);	
	}
	
	
	//useful for hangman
	/*public static char getChar()
	{
		String input=new String();
		char inputChar=' ';
		try
		{
			input=br.readLine();
		}
		catch (IOException e)
		{
			System.out.println("IO Error: " +e);
			System.out.print("Please re-enter input: ");
			return(getChar());
		}
		try
		{
			inputChar=Character.parseChar(input);
		}
		catch (NumberFormatException e)
		{
			System.out.println("Non Character Input Error: " +e);
			System.out.print("Please re-enter input: ");
			return(getChar());
		}	
		return(inputChar);
	}*/
	
	public static int randomInt(int upperBound) 
	{
		return(ran.nextInt(upperBound));
	}
	
	public static void cls()
	{
		for (int c=0; c<30; c++)
			System.out.println("");
	}
	
	public static void put(String input)
	{
		System.out.println(input);
	}
	
	public static final Color ranColors[] = {
	Color.red,
	Color.pink,
	Color.orange,
	Color.yellow,
	Color.green,
	Color.magenta,
	Color.blue,
	Color.cyan,
	Color.white,
	Color.gray,
	Color.lightGray,
	Color.darkGray
    };
    public static Color ranCol()
    {
    	final Color color=ranColors[randomInt(12)];
    	return(color);
    }
}