package project_2;
import java.io.File;
import java.util.Scanner;

import javafx.application.Application;
import javafx.stage.Stage;

public class Main  extends Application{

	static LinkedList<Equation> allEquatios= new LinkedList<>();
	static LinkedList<Equation> validEquations = new LinkedList<>();
	static LinkedList<Equation> invalidEquations = new LinkedList<>();

	public static void main(String[] args) {

		File f = new File("Equations.txt");
		Scanner in;
		String s="";
		
		//Reading Equation File and adding them in linkedList has all equations
		try {
			in = new Scanner(f);
			while(in.hasNext()){
				s=in.nextLine();
				if(!s.equals(""))
					allEquatios.add(new Equation(s));
				s="";
			}
		} 
		catch (Exception e) {
			System.exit(0);
		}

		//Determine whether the Equation is valid or not and add them in the proper LinkedLists
		
		for (int i = 0; i < allEquatios.getSize(); i++) {
			if(allEquatios.getIndexData(i).isEquationValid()){
				validEquations.add(allEquatios.getIndexData(i));
			}
			else{
				invalidEquations.add(allEquatios.getIndexData(i));
			}
		}


		launch(args);

		

	}

	@Override
	public void start(Stage primaryStage) throws Exception {
		// TODO Auto-generated method stub
		new MainScene(validEquations, invalidEquations,allEquatios).show();

	}





}
