package IAMdatabase;

import java.io.RandomAccessFile;

import GUI.mainWindow;
import java.util.ArrayList;

public class TestResult {
	
	public TestResult() {
	
	}
	
	public void run(){
		String file = new String("");
		ArrayList lineResult = new ArrayList();
		ArrayList result = new ArrayList();

		for (int i = 0; i < 2; i++) {
			lineResult = new ArrayList();
			result = new ArrayList();
			if (i == 0)
				file = "habitDataSame1.txt";
				//file = "habitDataSame1HABITSYSTEM.txt";
				//file = "habitDataSame1HABSYS.HIERCLUS.txt";
			else 
				file = "habitDataDiff1.txt";
				//file = "habitDataDiff1HABITSYSTEM100.txt";
				//file = "habitDataDiff1HABSYS.HIERCLUS100.txt";
				//file = "habitDataDiff1HABSYS.HIERCLUS.txt";
			try{
				//read file
			    RandomAccessFile rf = new RandomAccessFile("pics\\graphemes\\"+file, "r");
				String line = "";
				while ( (line = rf.readLine()) != null ) {
					lineResult.add(line);
				//	System.out.println("LINE "+line);
					result.add(line.substring(2, 6));
				//	System.out.println("RESULT "+result);
				}
			    rf.close();
			} catch (Exception e) {
				System.out.println("nieco zlyhalo pri citani");
			}	
			
			if (i == 0){
				System.out.println("SAME:");
				System.out.println("pocet: "+lineResult.size());
				int good = 0;
				int bad = 0;
				for (int j = 0; j < result.size(); j++) {
					if ( ((String)(result.get(j))).compareTo("SAME") == 0 )
						good++;
					else
						bad++;
				}
				System.out.println("dobrych: "+good);
				System.out.println("zlych: "+bad);
				System.out.println();
			} else 	if (i == 1){
				System.out.println("DIFF:");
				System.out.println("pocet: "+lineResult.size());
				int good = 0;
				int bad = 0;
				for (int j = 0; j < result.size(); j++) {
					if ( ((String)(result.get(j))).compareTo("DIFF") == 0 )
						good++;
					else
						bad++;
				}
				System.out.println("dobrych: "+good);
				System.out.println("zlych: "+bad);
			}
		}	
	}
	
	public static void main(String[] args) {
		TestResult tr = new TestResult();
		tr.run();
	}

}

