import java.util.Scanner;
/*************************************************************

NOTE: you will need to "flesh out" this class.  The method headers
are provided for you, but you must fill in all of the implementation
code and the documentation.  YOU MUST NOT CHANGE THE HEADERS.

You should write "stubs" for each of the methods, test it against
the tester programs, then fill in the methods themselves testing each
one independently.

**************************************************************/
public class myTools
{
	public int getInteger(Scanner scan, String prompt, String error, int dValue)
	{
	
		int result;
		
		System.out.print(prompt);
		if(scan.hasNextInt())
		{	
			result = scan.nextInt();
			System.out.println();
		}
		else
		{
			System.out.println();
			System.out.println(error);
			result = dValue;
		}
		
		return result;
	}
	
	public double getDouble(Scanner scan, String prompt, String error, int dValue)
	{
		
		double result;
		
		System.out.print(prompt);
		if(scan.hasNextDouble())
		{
			result = scan.nextDouble();
			System.out.println();
		}
		else
		{
			System.out.println();
			System.out.println(error);
			result = dValue;
		}	
		
		return result;
	}
	
	public boolean isInRange(int check, int low, int high, boolean inclusive)
	{
		
		boolean result;
		result = false;
		
		if(inclusive)
		{
			if(check >= low && check <= high)
				result = true;
		}
		else
		{
			if(check > low && check < high)
				result = true;
		}	
		
		return result;
	}
	
	public boolean isInRange(double check, double low, double high, boolean inclusive)
	{
		
		boolean result;
		result = false;
	
		if(inclusive)
		{
			if(check >= low && check <= high)
				result = true;
		}
		else
		{
			if(check > low && check < high)
				result = true;
		}		
		
		return result;
	}
	
	public boolean checkExpect(int check, int expect)
	{
	
		boolean result;
		result = false;
		
		if(check == expect)
			result = true;
		
		return result;
	}
	
	public boolean checkExpect(double check, double expect, double precision)
	{
		boolean result;
		result = false;
			
		if(Math.abs(check - expect) <= precision)
			result = true;
		
		return result;
	}
	
	public boolean checkExpect(String check, String expect, boolean matchCase)
	{

		boolean result;
		result = false;
		
		if(matchCase)
		{
			if(check.equals(expect))
				result = true;
		}
		else
		{
			if(check.equalsIgnoreCase(expect))
				result = true;
		}	
		
		return result;	
	}
	
}

