package edu.se459grp4.project.simulator;

import edu.se459grp4.project.simulator.gui.SimulatorGUI;
import edu.se459grp4.project.simulator.models.FloorTile;
import edu.se459grp4.project.simulator.util.FloorPlanReader;

import java.awt.*;
import java.io.*;

public class FloorSimulator {
    static final String DEFAULT_FLOOR_PLAN = "/sample-floor-plan.csv";
    FloorTile[][] floorTiles;
    Point cleanSweepPosition;

    public FloorSimulator(int cleanSweepX, int cleanSweepY, String floorPlanLocation) {
        cleanSweepPosition = new Point(cleanSweepX, cleanSweepY);
        loadFloorPlan(floorPlanLocation);
        SimulatorGUI gui = new SimulatorGUI(getFloorTiles());
        gui.start();
    }

    public void loadFloorPlan(String fileLocation) {
        InputStream inputStream = null;
        FileInputStream fileInputStream = null;
        InputStreamReader inputStreamReader = null;

        // Use default file in "resources" directory if no file location provided
        if(fileLocation == null) {
            inputStream = getClass().getResourceAsStream(FloorSimulator.DEFAULT_FLOOR_PLAN);
            inputStreamReader = new InputStreamReader(inputStream);
        }
        else {
            try {
                fileInputStream = new FileInputStream(fileLocation);
            }
            catch(FileNotFoundException e) {
                e.printStackTrace();
            }
            inputStreamReader = new InputStreamReader(fileInputStream) ;
        }

        FloorPlanReader floorPlanReader = new FloorPlanReader(inputStreamReader);
        this.floorTiles = floorPlanReader.getTileElements();
    }

    public FloorTile[][] getFloorTiles() {
        return floorTiles;
    }

    public FloorTile getFloorTile(int x, int y) {
        return floorTiles[x][y];
    }

    public FloorTile getCleanSweepFloorTile() {
        int cleanSweepX = cleanSweepPosition.getLocation().x;
        int cleanSweepY = cleanSweepPosition.getLocation().y;
        return floorTiles[cleanSweepX][cleanSweepY];
    }

}

@@ -149,16 +149,120 @@
 orTile;%0A
+import edu.se459grp4.project.simulator.types.Border;%0Aimport edu.se459grp4.project.simulator.types.Tile;%0A
 import e
@@ -2126,12 +2126,333 @@
 %5D;%0A    %7D
+%0A    %0A    public Border getBorder(String edge)%7B%0A    %09return null;%0A    %7D%0A    %0A    public int getDirtAmount()%7B%0A    %09return -1;%0A    %7D%0A    %0A    public Tile getTileType()%7B%0A    %09return null;%0A    %7D%0A    %0A    public boolean move(String direction)%7B%0A    %09return false;%0A    %7D%0A    %0A    public boolean clean()%7B%0A    %09return false;%0A    %7D
 %0A%0A%7D%0A

Add method stubs to FloorSimulator to communicate with Clean Sweep