import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.FileReader;

//Jason Kim
//CSE 630
//Compile: javac hw1reflex.java
//
//Homework 1 simple reflex agent:
//Instructions:
//This Java Program takes an arguement from Command Line
//ie to run type in console: java hw1reflex yourfile.txt


public class hw1reflex 
{  
    public static String SimpleReflexAgent(int perceived)
    {
		String action;
		if ( perceived%3==0)
		{
			action="G";
		}
		else
		{
			action="N";
		}
		return action;
	
    }
    public static void main(String[] args) 
	{
	
	 //Buffer Reader
	 BufferedReader buffr;
	 //Try To Read File from Command Line
	 try
	 {
	 	FileReader fr = new FileReader(args[0]);// file = commandline arguement
	 	buffr = new BufferedReader(fr);// 

	 } catch(IOException ioe){ throw new RuntimeException("Could not open file");}// Could not open file
        
        try
		{
	 		String line;
			String action;
			int perceived;
			while ((line = buffr.readLine()) != null) 
			{ //reads entire file
				
				perceived = Integer.valueOf( line ).intValue();
				action = SimpleReflexAgent(perceived);
				System.out.println("Perceived: " + perceived + " Action: " + action);

			}
		} catch(IOException ioe){throw new RuntimeException("Could not Read Line");}//if can't read file line
    }
}


