package model;

import java.io.*;

public class TitanDSM {
    private int sizeOfMatrix;
    private int[][] dataMatrix;
    private String[] nameOfClass;

    public TitanDSM(int sizeOfMatrix) {
        this.sizeOfMatrix = sizeOfMatrix;
        dataMatrix = new int[sizeOfMatrix][sizeOfMatrix];
        nameOfClass = new String[sizeOfMatrix];
    }

    public TitanDSM(File file) throws IOException {
        loadFromFile(file);
    }

    public int getSize() {
        return sizeOfMatrix;
    }

    public void setSize(int size) {
        sizeOfMatrix = size;
    }

    public int[][] getDataMatrix() {
        return dataMatrix;
    }

    public void setData(int data, int row, int col) {
        dataMatrix[row][col] = data;
    }

    public String[] getNames() {
        return nameOfClass;
    }

    public void loadFromFile(File dsm) throws IOException {
        BufferedReader fileReader = new BufferedReader(new FileReader(dsm));
        String read;
        String[] temp;

        read = fileReader.readLine();
        sizeOfMatrix = Integer.parseInt(read);

        dataMatrix = new int[sizeOfMatrix][sizeOfMatrix];
        nameOfClass = new String[sizeOfMatrix];

        for (int i = 0; i < sizeOfMatrix; i++) {
            read = fileReader.readLine();
            temp = read.split(" ");
            for (int j = 0; j < sizeOfMatrix; j++) {
                dataMatrix[i][j] = Integer.parseInt(temp[j]);
            }
        }

        for (int i = 0; i < sizeOfMatrix; i++) {
            read = fileReader.readLine();
            nameOfClass[i] = read;
        }
    }

    public void saveToFile(String fileName) throws IOException{
        BufferedWriter out = new BufferedWriter(new FileWriter(fileName));

        out.write(String.valueOf(sizeOfMatrix));
        out.newLine();

        for(int i = 0; i < sizeOfMatrix; i++) {
            for(int j = 0; j < sizeOfMatrix; j++) {
                out.write(dataMatrix[i][j] + " ");
            }
            out.newLine();
        }

        for(int i = 0; i < sizeOfMatrix; i++) {
            out.write(nameOfClass[i]);
            out.newLine();
        }

        out.close();
    }

}
@@ -94,19 +94,23 @@
 private 
-int
+boolean
 %5B%5D%5B%5D dat
@@ -252,35 +252,39 @@
 ataMatrix = new 
-int
+boolean
 %5BsizeOfMatrix%5D%5Bs
@@ -585,19 +585,23 @@
  public 
-int
+boolean
 %5B%5D%5B%5D get
@@ -673,19 +673,23 @@
 setData(
-int
+boolean
  data, i
@@ -1112,19 +1112,23 @@
 x = new 
-int
+boolean
 %5BsizeOfM
@@ -1438,16 +1438,21 @@
 temp%5Bj%5D)
+ == 1
 ;%0A      
@@ -1601,24 +1601,53 @@
 d;%0A        %7D
+%0A%0A        fileReader.close();
 %0A    %7D%0A%0A    

modify dataMatrix type int to boolean