Similar Code Analysis Report

This document contains the results of performing a similar code analysis of projectscellsociety_team02 at 9/29/16 2:15 PM.

Table of contents

number of lines number of occurrences names of resources
14..10 2 PredatorPreyCell
9 2 SegregationSim
10 4 Simulation
5 2 PredatorPreyState, SegregationState
4..3 2 Simulation, Menu
12 3 GameOfLifeHexagonalSim, GameOfLifeTriangleSim, GameOfLifeSqSim
4..3 2 PredatorPreySim, FireSim
6 4 PredatorPreySim
9 2 GameOfLifeHexagonalSim
14 3 GameOfLifeHexagonalSim, GameOfLifeTriangleSim, GameOfLifeSqSim
3 2 FireSim
1 2 SegregationState, PredatorPreySim
9 2 GameOfLifeTriangleSim
3 4 PredatorPreySim, SegregationSim, GameOfLifeSqSim, FireSim
8 3 GameOfLifeHexagonalSim, GameOfLifeTriangleSim, GameOfLifeSqSim
11 6 GameOfLifeHexagonalSim, GameOfLifeTriangleSim, PredatorPreySim, SegregationSim, GameOfLifeSqSim, FireSim
16 2 FireState, GOLState
6 2 PredatorPreySim
7..6 2 SegregationSim, FireSim
7..6 2 SegregationSim, FireSim
5 2 PredatorPreyState, SegregationState
8..7 3 XMLParser
5 3 GameOfLifeHexagonalSim, GameOfLifeTriangleSim, GameOfLifeSqSim
5 2 Simulation, Menu
5 3 GameOfLifeHexagonalSim, GameOfLifeTriangleSim, GameOfLifeSqSim
9..8 6 GameOfLifeHexagonalSim, GameOfLifeTriangleSim, PredatorPreySim, SegregationSim, GameOfLifeSqSim, FireSim
5 2 PredatorPreySim

List of matches

 

10 lines in Simulation (x4)


Simulation
/cellsociety_team02/src/cellsociety_team02/Simulation.java
Simulation
/cellsociety_team02/src/cellsociety_team02/Simulation.java
Simulation
/cellsociety_team02/src/cellsociety_team02/Simulation.java
Simulation
/cellsociety_team02/src/cellsociety_team02/Simulation.java
    protected Button getMenuButton(){ 
        Button b = new Button("Main menu"); 
        b.setOnAction(new EventHandler<ActionEvent>(){ 
            @Override 
            public void handle(ActionEvent e){ 
                manager.switchToMenu(new Menu(manager)); 
            } 
        }); 
        return b; 
    } 
    protected Button getSlowerButton(){ 
        Button b = new Button("Slower"); 
        b.setOnAction(new EventHandler<ActionEvent>(){ 
            @Override 
            public void handle(ActionEvent e){ 
                interval += changeSpeed; 
            } 
        }); 
        return b; 
    } 
    protected Button getUpdateButton(){ 
        Button b = new Button("Step"); 
        b.setOnAction(new EventHandler<ActionEvent>(){ 
            @Override 
            public void handle(ActionEvent e){ 
                update(); 
            } 
        }); 
        return b; 
    } 
    protected Button getFasterButton(){ 
        Button b = new Button("Faster"); 
        b.setOnAction(new EventHandler<ActionEvent>(){ 
            @Override 
            public void handle(ActionEvent e){ 
                interval -= changeSpeed; 
            } 
        }); 
        return b; 
    } 
 

12 lines in GameOfLifeHexagonalSim, GameOfLifeTriangleSim, GameOfLifeSqSim


GameOfLifeHexagonalSim
/cellsociety_team02/src/cellsociety_team02/GameOfLifeHexagonalSim.java
GameOfLifeSqSim
/cellsociety_team02/src/cellsociety_team02/GameOfLifeSqSim.java
GameOfLifeTriangleSim
/cellsociety_team02/src/cellsociety_team02/GameOfLifeTriangleSim.java
    protected void update(){ 
        Cell[][] temp = new Cell[getGrid().length][getGrid()[0].length]; 
        copy(temp); 
        for(int i = 0; i < getGrid().length; i++){ 
            for(int j = 0; j < getGrid()[i].length; j++){ 
                GOLCell g = (GOLCell) getGrid()[i][j]; 
                GOLCell t = (GOLCell) temp[i][j]; 
                g.changeAlive((GOLCell.State) t.updateState()); 
            } 
        } 
        changeState(); 
    } 
    protected void update(){ 
        Cell[][] temp = new Cell[getGrid().length][getGrid()[0].length]; 
        copy(temp); 
        for(int i = 0; i < getGrid().length; i++){ 
            for(int j = 0; j < getGrid()[i].length; j++){ 
                GOLCell g = (GOLCell) getGrid()[i][j]; 
                GOLCell t = (GOLCell) temp[i][j]; 
                g.changeAlive((GOLCell.State) t.updateState()); 
            } 
        } 
        changeState(); 
    } 
    protected void update(){ 
        Cell[][] temp = new Cell[getGrid().length][getGrid()[0].length]; 
        copy(temp); 
        for(int i = 0; i < getGrid().length; i++){ 
            for(int j = 0; j < getGrid()[i].length; j++){ 
                GOLCell g = (GOLCell) getGrid()[i][j]; 
                GOLCell t = (GOLCell) temp[i][j]; 
                g.changeAlive((GOLCell.State) t.updateState()); 
            } 
        } 
        changeState(); 
    } 
 

6 lines in PredatorPreySim (x4)


PredatorPreySim
/cellsociety_team02/src/cellsociety_team02/PredatorPreySim.java
PredatorPreySim
/cellsociety_team02/src/cellsociety_team02/PredatorPreySim.java
PredatorPreySim
/cellsociety_team02/src/cellsociety_team02/PredatorPreySim.java
PredatorPreySim
/cellsociety_team02/src/cellsociety_team02/PredatorPreySim.java
    private void updateBreedFish(Cell[][] copy){ 
        for(int i = 0; i < getGrid().length; i++){ 
            for(int j = 0; j < getGrid()[i].length; j++){ 
                PredatorPreyCell g = (PredatorPreyCell) getGrid()[i][j]; 
                PredatorPreyCell t = (PredatorPreyCell) copy[i][j]; 
                if(t.getState() == PredatorPreyCell.State.FISH){ 
    private void updateMoveShark(Cell[][] copy){ 
        for(int i = 0; i < getGrid().length; i++){ 
            for(int j = 0; j < getGrid()[i].length; j++){ 
                PredatorPreyCell g = (PredatorPreyCell) getGrid()[i][j]; 
                PredatorPreyCell t = (PredatorPreyCell) copy[i][j]; 
                if(t.getState() == PredatorPreyCell.State.SHARK){ 
    private void updateBreedShark(Cell[][] copy){ 
        for(int i = 0; i < getGrid().length; i++){ 
            for(int j = 0; j < getGrid()[i].length; j++){ 
                PredatorPreyCell g = (PredatorPreyCell) getGrid()[i][j]; 
                PredatorPreyCell t = (PredatorPreyCell) copy[i][j]; 
                if(t.getState() == PredatorPreyCell.State.SHARK){ 
    private void updateMoveFish(Cell[][] copy){ 
        for(int i = 0; i < getGrid().length; i++){ 
            for(int j = 0; j < getGrid()[i].length; j++){ 
                PredatorPreyCell g = (PredatorPreyCell) getGrid()[i][j]; 
                PredatorPreyCell t = (PredatorPreyCell) copy[i][j]; 
                if(t.getState() == PredatorPreyCell.State.FISH){ 
 

14 lines in GameOfLifeHexagonalSim, GameOfLifeTriangleSim, GameOfLifeSqSim


GameOfLifeHexagonalSim
/cellsociety_team02/src/cellsociety_team02/GameOfLifeHexagonalSim.java
GameOfLifeSqSim
/cellsociety_team02/src/cellsociety_team02/GameOfLifeSqSim.java
GameOfLifeTriangleSim
/cellsociety_team02/src/cellsociety_team02/GameOfLifeTriangleSim.java
    private void copy(Cell[][] c){ 
        for (int i = 0; i < getGrid().length; i++) { 
            for(int j = 0; j < getGrid()[i].length; j++){ 
                GOLCell g = (GOLCell) getGrid()[i][j]; 
                GOLCell t = new GOLCell(g.checkAlive(), g.getRow(), g.getCol()); 
                for(int k = 0; k < g.getNeighbors().size(); k++){ 
                    GOLCell temp = (GOLCell) g.getNeighbors().get(k); 
                    GOLCell add = new GOLCell(temp.checkAlive(), temp.getRow(), temp.getCol()); 
                    t.getNeighbors().add(add); 
                } 
                c[i][j] = t; 
            } 
        } 
    } 
    private void copy(Cell[][] c){ 
        for (int i = 0; i < getGrid().length; i++) { 
            for(int j = 0; j < getGrid()[i].length; j++){ 
                GOLCell g = (GOLCell) getGrid()[i][j]; 
                GOLCell t = new GOLCell(g.checkAlive(), g.getRow(), g.getCol()); 
                for(int k = 0; k < g.getNeighbors().size(); k++){ 
                    GOLCell temp = (GOLCell) g.getNeighbors().get(k); 
                    GOLCell add = new GOLCell(temp.checkAlive(), temp.getRow(), temp.getCol()); 
                    t.getNeighbors().add(add); 
                } 
                c[i][j] = t; 
            } 
        } 
    } 
    private void copy(Cell[][] c){ 
        for (int i = 0; i < getGrid().length; i++) { 
            for(int j = 0; j < getGrid()[i].length; j++){ 
                GOLCell g = (GOLCell) getGrid()[i][j]; 
                GOLCell t = new GOLCell(g.checkAlive(), g.getRow(), g.getCol()); 
                for(int k = 0; k < g.getNeighbors().size(); k++){ 
                    GOLCell temp = (GOLCell) g.getNeighbors().get(k); 
                    GOLCell add = new GOLCell(temp.checkAlive(), temp.getRow(), temp.getCol()); 
                    t.getNeighbors().add(add); 
                } 
                c[i][j] = t; 
            } 
        } 
    } 
 

8 lines in GameOfLifeHexagonalSim, GameOfLifeTriangleSim, GameOfLifeSqSim


GameOfLifeSqSim
/cellsociety_team02/src/cellsociety_team02/GameOfLifeSqSim.java
GameOfLifeHexagonalSim
/cellsociety_team02/src/cellsociety_team02/GameOfLifeHexagonalSim.java
GameOfLifeTriangleSim
/cellsociety_team02/src/cellsociety_team02/GameOfLifeTriangleSim.java
    private void changeState(){ 
        for(int i = 0; i < getGrid().length; i++) { 
            for (int j = 0; j < getGrid()[i].length; j++) { 
                GOLCell g = (GOLCell) getGrid()[i][j]; 
                g.getCell().setFill(getStates().get(g.checkAlive())); 
            } 
        } 
    } 
    private void changeState(){ 
        for(int i = 0; i < getGrid().length; i++) { 
            for (int j = 0; j < getGrid()[i].length; j++) { 
                GOLCell g = (GOLCell) getGrid()[i][j]; 
                g.getCell().setFill(getStates().get(g.checkAlive())); 
            } 
        } 
    } 
    private void changeState(){ 
        for(int i = 0; i < getGrid().length; i++) { 
            for (int j = 0; j < getGrid()[i].length; j++) { 
                GOLCell g = (GOLCell) getGrid()[i][j]; 
                g.getCell().setFill(getStates().get(g.checkAlive())); 
            } 
        } 
    } 
 

11 lines in 6 files: GameOfLifeHexagonalSim, GameOfLifeTriangleSim, PredatorPreySim, SegregationSim, GameOfLifeSqSim, FireSim


FireSim
/cellsociety_team02/src/cellsociety_team02/FireSim.java
GameOfLifeHexagonalSim
/cellsociety_team02/src/cellsociety_team02/GameOfLifeHexagonalSim.java
PredatorPreySim
/cellsociety_team02/src/cellsociety_team02/PredatorPreySim.java
GameOfLifeSqSim
/cellsociety_team02/src/cellsociety_team02/GameOfLifeSqSim.java
    protected Button getResetButton(){ 
        Button b = new Button("Reset"); 
        b.setOnAction(new EventHandler<ActionEvent>(){ 
            @Override 
            public void handle(ActionEvent e){ 
                animate.stop(); 
                getManager().switchToSimulation(new FireSim(getManager(), Main.getRows())); 
            } 
        }); 
        return b; 
    } 
    protected Button getResetButton(){ 
        Button b = new Button("Reset"); 
        b.setOnAction(new EventHandler<ActionEvent>(){ 
            @Override 
            public void handle(ActionEvent e){ 
                animate.stop(); 
                getManager().switchToSimulation(new GameOfLifeHexagonalSim(getManager(), Main.getRows())); 
            } 
        }); 
        return b; 
    } 
    protected Button getResetButton(){ 
        Button b = new Button("Reset"); 
        b.setOnAction(new EventHandler<ActionEvent>(){ 
            @Override 
            public void handle(ActionEvent e){ 
                animate.stop(); 
                getManager().switchToSimulation(new PredatorPreySim(getManager(), Main.getRows())); 
            } 
        }); 
        return b; 
    } 
    protected Button getResetButton(){ 
        Button b = new Button("Reset"); 
        b.setOnAction(new EventHandler<ActionEvent>(){ 
            @Override 
            public void handle(ActionEvent e){ 
                animate.stop(); 
                getManager().switchToSimulation(new GameOfLifeSqSim(getManager(), Main.getRows())); 
            } 
        }); 
        return b; 
    } 
 

16 lines in FireState, GOLState


GOLState
/cellsociety_team02/src/cellsociety_team02/GOLState.java
FireState
/cellsociety_team02/src/cellsociety_team02/FireState.java
   @Override 
   protected void createGrid(int gridDim){ 
      for(int i = 0; i < gridDim; i++){ 
         for(int j = 0; j < gridDim; j++){ 
            getGrid()[i][j] = new GOLCell(GOLCell.State.DEAD, i, j); 
         } 
      } 
      NodeList filledCells = getStateElement().getElementsByTagName("cell"); 
      for(int k = 0; k < filledCells.getLength(); k++){ 
         Element newCell = (Element) filledCells.item(k); 
         int xPos = Integer.parseInt(newCell.getAttribute("x")); 
         int yPos = Integer.parseInt(newCell.getAttribute("y")); 
         getGrid()[xPos][yPos] = new GOLCell(GOLCell.State.ALIVE, xPos, yPos); 
      } 
       
   } 
   @Override 
   protected void createGrid(int gridDim){ 
      for(int i = 0; i < gridDim; i++){ 
         for(int j = 0; j < gridDim; j++){ 
            getGrid()[i][j] = new FireCell(FireCell.State.TREE, i, j); 
         } 
      } 
      NodeList filledCells = getStateElement().getElementsByTagName("cell"); 
      for(int k = 0; k < filledCells.getLength(); k++){ 
         Element newCell = (Element) filledCells.item(k); 
         int xPos = Integer.parseInt(newCell.getAttribute("x")); 
         int yPos = Integer.parseInt(newCell.getAttribute("y")); 
         getGrid()[xPos][yPos] = new FireCell(FireCell.State.BURNING, xPos, yPos); 
      } 
       
   } 
 

8..9 lines in 6 files: GameOfLifeHexagonalSim, GameOfLifeTriangleSim, PredatorPreySim, SegregationSim, GameOfLifeSqSim, FireSim


GameOfLifeSqSim
/cellsociety_team02/src/cellsociety_team02/GameOfLifeSqSim.java
GameOfLifeTriangleSim
/cellsociety_team02/src/cellsociety_team02/GameOfLifeTriangleSim.java
PredatorPreySim
/cellsociety_team02/src/cellsociety_team02/PredatorPreySim.java
FireSim
/cellsociety_team02/src/cellsociety_team02/FireSim.java
   protected void initGrid(){ 
      newParse.loadFile("data/gameoflife.xml"); 
      ArrayList<InitialState> stateList= newParse.getStateList(); 
      Main.setRows(newParse.getGridDim()); 
      Main.setCols(newParse.getGridDim()); 
      setSizeCell(Main.SIZE_GRID/newParse.getGridDim()); 
      setGrid(stateList.get(currentState).getGrid());     
   } 
   protected void initGrid(){ 
      newParse.loadFile("data/gameoflife.xml"); 
      ArrayList<InitialState> stateList= newParse.getStateList(); 
      Main.setRows(newParse.getGridDim()); 
      Main.setCols(newParse.getGridDim()); 
      setSizeCell(Main.SIZE_GRID/newParse.getGridDim()); 
      setGrid(stateList.get(currentState).getGrid());  
       
   } 
    protected void initGrid(){ 
       newParse.loadFile("data/predatorprey.xml"); 
      ArrayList<InitialState> stateList= newParse.getStateList(); 
      Main.setRows(newParse.getGridDim()); 
      Main.setCols(newParse.getGridDim()); 
      setSizeCell(Main.SIZE_GRID/newParse.getGridDim()); 
      setGrid(stateList.get(currentState).getGrid()); 
    
    protected void initGrid(){ 
          newParse.loadFile("data/firesim.xml"); 
          ArrayList<InitialState> stateList= newParse.getStateList(); 
          Main.setRows(newParse.getGridDim()); 
          Main.setCols(newParse.getGridDim()); 
          setSizeCell(Main.SIZE_GRID/newParse.getGridDim()); 
          setGrid(stateList.get(currentState).getGrid());  
 
    
9/29/16 2:15 PM Powered by CodePro Server