Similar Code Analysis Report

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

Table of contents

number of lines number of occurrences names of resources
12 2 FireSimulation, GameOfLifeSimulation
14..11 3 GameOfLifeSimulation, SegregationSimulation, PredatorPreySimulation
15..13 2 PredatorPreySimulation
8..7 2 GameOfLifeSimulation, SegregationSimulation
5..4 2 FireSimulation, SegregationSimulation
9 3 GameOfLifeSimulation, SegregationSimulation, PredatorPreySimulation
14..11 3 PredData, SegregationData, FireData
4 2 Simulation
4..3 3 Simulation, GameOfLifeSimulation, SegregationSimulation
15 2 GameOfLifeSimulation, SegregationSimulation
4 2 PredatorPreySimulation
15 2 FireSimulation, PredatorPreySimulation
4 2 PredatorPreySimulation
4 2 PredatorPreySimulation
5 4 Simulation
7 3 FireSimulation, SegregationSimulation, PredatorPreySimulation
6 2 PredatorPreySimulation
5 2 DataXMLFactory
7 2 DataXMLFactory
4 2 FireSimulation, SegregationSimulation
3 2 GameOfLifeSimulation, PredatorPreySimulation

List of matches

 

12 lines in FireSimulation, GameOfLifeSimulation


FireSimulation
/cellsociety_team07/src/cellsociety_team07/FireSimulation.java
GameOfLifeSimulation
/cellsociety_team07/src/cellsociety_team07/GameOfLifeSimulation.java
               nextState[row][col] = new State(stateEmpty); 
            } 
             
            if (cell.getState().equals(new State(stateTree))) { 
               List<Cell> neighbors = cell.getNeighborhood().getNeighbors(); 
               if (doesTreeBecomeBurning(neighbors)) { 
                  nextState[row][col] = new State(stateBurning); 
               } 
               else { 
                  nextState[row][col] = new State(stateTree); 
               } 
            } 
                  nextState[row][col] =  new State(stateAlive); 
               } 
            } 
             
            if (cell.getState().equals(new State(stateDead))) { 
               if (aliveNeighbors == 3) { 
                  nextState[row][col] =  new State(stateAlive); 
               } 
               else { 
                  nextState[row][col] = new State(stateDead); 
               } 
            } 
 

11..14 lines in GameOfLifeSimulation, SegregationSimulation, PredatorPreySimulation


SegregationSimulation
/cellsociety_team07/src/cellsociety_team07/SegregationSimulation.java
GameOfLifeSimulation
/cellsociety_team07/src/cellsociety_team07/GameOfLifeSimulation.java
PredatorPreySimulation
/cellsociety_team07/src/cellsociety_team07/PredatorPreySimulation.java
   private State generateRandomState() { 
      Random r = new Random(); 
      int i = r.nextInt(4); 
       
      if (i == 0) { 
         return new State(stateX); 
      } 
      if (i == 1) { 
         return new State(stateO); 
      } 
      else { 
         return new State(stateEmpty); 
      } 
   } 
   private State generateRandomState() { 
      Random r = new Random(); 
      int i = r.nextInt(4); 
       
      if (i == 0) { 
         return new State(stateAlive); 
      } 
      else { 
         return new State(stateDead); 
      } 
   } 
   private State generateRandomState() { 
      Random r = new Random(); 
      int i = r.nextInt(10); 
       
      if (i == 0) { 
         return new State(stateShark); 
      } 
      if (i == 1 || i == 2 || i == 3) { 
         return new State(stateFish); 
      } 
      else { 
         return new State(stateEmpty); 
      } 
   } 
 

11..14 lines in PredData, SegregationData, FireData


SegregationData
/cellsociety_team07/src/xml/SegregationData.java
FireData
/cellsociety_team07/src/xml/FireData.java
PredData
/cellsociety_team07/src/xml/PredData.java
    public String toString () { 
        StringBuilder result = new StringBuilder(); 
        result.append("Data{") 
              .append("title='").append(getMyTitle()).append("', ") 
              .append("author='").append((getMyAuthor())).append("', ") 
              .append("numRows='").append((getMyNumRows())).append("', ") 
              .append("numCols='").append((getMyNumCols())).append("', ") 
              .append("threshold='").append(getMyThreshold()).append("'") 
              .append('}'); 
       return result.toString(); 
    } 
    public String toString () { 
        StringBuilder result = new StringBuilder(); 
        result.append("Data{") 
              .append("title='").append(getMyTitle()).append("', ") 
              .append("author='").append((getMyAuthor())).append("', ") 
              .append("numRows='").append((getMyNumRows())).append("', ") 
              .append("numCols='").append((getMyNumCols())).append("', ") 
              .append("probCatch='").append(getMyProbCatch()).append("', ") 
              .append("initialFire='").append(getMyInitialFire()).append("'") 
              .append('}'); 
       return result.toString(); 
    } 
    public String toString () { 
        StringBuilder result = new StringBuilder(); 
        result.append("Data{") 
              .append("title='").append(getMyTitle()).append("', ") 
              .append("author='").append((getMyAuthor())).append("', ") 
              .append("numRows='").append((getMyNumRows())).append("', ") 
              .append("numCols='").append((getMyNumCols())).append("', ") 
              .append("fishBreed='").append((getMyFishBreed())).append("', ") 
              .append("fishStarve='").append((getMyFishStarve())).append("', ") 
              .append("sharkBreed='").append((getMySharkBreed())).append("', ") 
              .append("sharkStarve='").append((getMySharkStarve())).append("'") 
              .append('}'); 
       return result.toString(); 
    } 
 

15 lines in GameOfLifeSimulation, SegregationSimulation


GameOfLifeSimulation
/cellsociety_team07/src/cellsociety_team07/GameOfLifeSimulation.java
SegregationSimulation
/cellsociety_team07/src/cellsociety_team07/SegregationSimulation.java
   @Override 
   protected void calculateNeighbors(Cell cell, int row, int col) { 
      for (int i = -1; i <= 1; i++) { 
         for (int j = -1; j <= 1; j++) { 
            if (i == 0 && j == 0) { 
               continue; 
            } 
            if (i + row < 0 || i + row >= rows || j + col < 0 || j + col >= columns) { 
               continue; 
            } 
            Cell neighbor = grid.getCell(row + i, col + j); 
            cell.getNeighborhood().addNeighbor(neighbor); 
         } 
      } 
   } 
   @Override 
   protected void calculateNeighbors(Cell cell, int row, int col) { 
      for (int i = -1; i <= 1; i++) { 
         for (int j = -1; j <= 1; j++) { 
            if (i == 0 && j == 0) { 
               continue; 
            } 
            if (i + row < 0 || i + row >= rows || j + col < 0 || j + col >= columns) { 
               continue; 
            } 
            Cell neighbor = grid.getCell(row + i, col + j); 
            cell.getNeighborhood().addNeighbor(neighbor); 
         } 
      } 
   } 
 

15 lines in FireSimulation, PredatorPreySimulation


PredatorPreySimulation
/cellsociety_team07/src/cellsociety_team07/PredatorPreySimulation.java
FireSimulation
/cellsociety_team07/src/cellsociety_team07/FireSimulation.java
   @Override 
   protected void calculateNeighbors(Cell cell, int row, int col) { 
      Point[] neighborDisplacements = {new Point(1,0), new Point(-1,0), new Point(0,1), new Point(0,-1)}; 
       
      for (Point neighborDisplacement : neighborDisplacements) { 
         int i = neighborDisplacement.x; 
         int j = neighborDisplacement.y; 
          
         if (i + row < 0 || i + row >= rows || j + col < 0 || j + col >= columns) { 
            continue; 
         } 
         Cell neighbor = grid.getCell(row + i, col + j); 
         cell.getNeighborhood().addNeighbor(neighbor); 
      } 
   } 
   @Override 
   protected void calculateNeighbors(Cell cell, int row, int col) { 
      Point[] neighborDisplacements = {new Point(1,0), new Point(-1,0), new Point(0,1), new Point(0,-1)}; 
       
      for (Point neighborDisplacement : neighborDisplacements) { 
         int i = neighborDisplacement.x; 
         int j = neighborDisplacement.y; 
          
         if (i + row < 0 || i + row >= rows || j + col < 0 || j + col >= columns) { 
            continue; 
         } 
         Cell neighbor = grid.getCell(row + i, col + j); 
         cell.getNeighborhood().addNeighbor(neighbor); 
      } 
   } 
9/29/16 2:17 PM Powered by CodePro Server