Similar Code Analysis Report

This document contains the results of performing a similar code analysis of projectscellsociety_team01 at 9/29/16 10:56 AM.

Table of contents

number of lines number of occurrences names of resources
8..7 2 GridController, XmlReader
7..5 2 XOGridLogic, WaterGridLogic
12..8 2 Shark, Fish
7 2 TreeGrid, LifeGrid
6..5 2 HexagonalFiniteGrid, HexagonalToroidalGrid
3 3 TreeGridLogic, WaterGridLogic, LifeGridLogic
22..20 2 AliveCell, DeadCell
8..7 2 XmlReader
27..26 3 TreeGridLogic, WaterGridLogic, LifeGridLogic
16..14 4 TreeXML, XOXML, WaterXML, LifeXML
7 2 BasicToroidalGrid, HexagonalToroidalGrid
6 2 HexagonalGridView, TriangleGridView
8..6 2 Shark, Fish
8..6 3 XmlReader
8 2 TreeGrid, LifeGrid
5 3 AliveCell, DeadCell, TreeCell
4 2 XOGridLogic, GridLogic
15 3 XOXMLFactory, LifeXMLFactory, WaterXMLFactory
3 2 BasicToroidalGrid, HexagonalToroidalGrid
4 2 BasicToroidalGrid, HexagonalToroidalGrid
5 3 XOXML, WaterXML, LifeXML
4..3 2 HexagonalGridView, TriangleGridView

List of matches

 

20..22 lines in AliveCell, DeadCell


DeadCell
/cellsociety_team01/src/life/DeadCell.java
AliveCell
/cellsociety_team01/src/life/AliveCell.java
   private boolean determineNextState() { 
      int numAlive = 0; 
      for (Cell c : neighbors) { 
         if (c instanceof AliveCell) { 
            numAlive++; 
         } 
      } 
      // If less than 2 neighboring cells are alive, cell dies of under 
      // population. 
      if (numAlive < 2) { 
         return false; 
      } 
      // If cell has 2 or 3 neighboring alive cells, cell stays alive. 
      if (numAlive == 2 || numAlive == 3) { 
         return true; 
      } 
      // If cell has more than 3 neighboring alive cells, cell dies of over 
      // population. 
      else { 
         return false; 
      } 
   } 
   private boolean determineNextState() { 
      int numAlive = 0; 
      for (Cell c: neighbors) { 
         if (c instanceof AliveCell ) { 
            numAlive++; 
         } 
      } 
      // If less than 2 neighboring cells are alive, cell dies of under population. 
      if (numAlive < 2) { 
         return false; 
      } 
      // If cell has 2 or 3 neighboring alive cells, cell stays alive. 
      if (numAlive == 2 || numAlive == 3) { 
         return true; 
      } 
      // If cell has more than 3 neighboring alive cells, cell dies of over population. 
      else { 
         return false; 
      } 
   } 
 

26..27 lines in TreeGridLogic, WaterGridLogic, LifeGridLogic


LifeGridLogic
/cellsociety_team01/src/life/LifeGridLogic.java
TreeGridLogic
/cellsociety_team01/src/tree/TreeGridLogic.java
WaterGridLogic
/cellsociety_team01/src/water/WaterGridLogic.java
   @Override 
   public void step() { 
      cellSizes.clear(); 
      // test print 
//      for (int r = 0; r < grid.getRows(); r++) { 
//         for (int c = 0; c < grid.getColumns(); c++) { 
//            System.out.print(grid.getGridIndex(r, c).toString() + " "); 
//         } 
//         System.out.println(); 
//      } 
//      System.out.println(); 
       
      // check state 
      for (int r = 0; r < grid.getRows(); r++) { 
         for (int c = 0; c < grid.getColumns(); c++) { 
            checkState(grid.getGridIndex(r, c), grid.getNeighbors(r, c)); 
         } 
      } 
 
      // update grid based on states 
      for (int r = 0; r < grid.getRows(); r++) { 
         for (int c = 0; c < grid.getColumns(); c++) { 
            updateGrid(grid.getGridIndex(r, c)); 
         } 
      } 
   } 
   @Override 
   public void step() { 
      cellSizes.clear(); 
      // test print 
//      for (int r = 0; r < grid.getRows(); r++) { 
//         for (int c = 0; c < grid.getColumns(); c++) { 
//            System.out.print(grid.getGridIndex(r, c).toString() + " "); 
//         } 
//         System.out.println(); 
//      } 
//      System.out.println(); 
       
      // check state 
      for (int r = 0; r < grid.getRows(); r++) { 
         for (int c = 0; c < grid.getColumns(); c++) { 
            checkState(grid.getGridIndex(r, c), grid.getNeighbors(r, c)); 
         } 
      } 
 
      // update grid based on states 
      for (int r = 0; r < grid.getRows(); r++) { 
         for (int c = 0; c < grid.getColumns(); c++) { 
            updateGrid(grid.getGridIndex(r, c)); 
         } 
      } 
   } 
   @Override 
   public void step() { 
      cellSizes.clear(); 
      // // test print 
      // for (int r = 0; r < grid.getRows(); r++) { 
      // for (int c = 0; c < grid.getColumns(); c++) { 
      // System.out.print(grid.getGridIndex(r, c).toString() + " "); 
      // 
      // System.out.println(); 
      // 
      // System.out.println(); 
 
      // check state 
      for (int r = 0; r < grid.getRows(); r++) { 
         for (int c = 0; c < grid.getColumns(); c++) { 
            checkState(grid.getGridIndex(cr), grid.getNeighbors(cr)); 
         } 
      } 
 
      // update grid based on states 
      for (int r = 0; r < grid.getRows(); r++) { 
         for (int c = 0; c < grid.getColumns(); c++) { 
            updateGrid(grid.getGridIndex(cr)); 
         } 
      } 
 
   } 
 

14..16 lines in TreeXML, XOXML, WaterXML, LifeXML


XOXML
/cellsociety_team01/src/xo/XOXML.java
WaterXML
/cellsociety_team01/src/water/WaterXML.java
LifeXML
/cellsociety_team01/src/life/LifeXML.java
TreeXML
/cellsociety_team01/src/tree/TreeXML.java
   @Override 
    public String toString () { 
        StringBuilder result = new StringBuilder(); 
        result.append("GameOfLife{") 
              .append("simulationName='").append(getName()).append("', ") 
              .append("simulationTitle='").append(getTitle()).append("', ") 
              .append("simulationAuthor='").append(getAuthor()).append("', ") 
              .append("xSize='").append(getXSize()).append("', ") 
              .append("ySize='").append(getYSize()).append("'. ") 
              .append("percentX='").append(getPercentX()).append("', ") 
              .append("percentO='").append(getPercentO()).append("', ") 
              .append('}'); 
       return result.toString(); 
    } 
   @Override 
    public String toString () { 
        StringBuilder result = new StringBuilder(); 
        result.append("GameOfLife{") 
              .append("simulationName='").append(getName()).append("', ") 
              .append("simulationTitle='").append(getTitle()).append("', ") 
              .append("simulationAuthor='").append(getAuthor()).append("', ") 
              .append("xSize='").append(getXSize()).append("', ") 
              .append("ySize='").append(getYSize()).append("'. ") 
              .append("percentFish='").append(getPercentFish()).append("', ") 
              .append("percentShark='").append(getPercentShark()).append("', ") 
              .append('}'); 
       return result.toString(); 
    } 
   @Override 
    public String toString () { 
        StringBuilder result = new StringBuilder(); 
        result.append("GameOfLife{") 
              .append("simulationName='").append(getName()).append("', ") 
              .append("simulationTitle='").append(getTitle()).append("', ") 
              .append("simulationAuthor='").append(getAuthor()).append("', ") 
              .append("xSize='").append(getXSize()).append("', ") 
              .append("ySize='").append(getYSize()).append("'. ") 
              .append("percentAlive='").append(getPercentAlive()).append("', ") 
              .append("percentDead='").append(getPercentDead()).append("', ") 
              .append('}'); 
       return result.toString(); 
    } 
   @Override 
    public String toString () { 
        StringBuilder result = new StringBuilder(); 
        result.append("GameOfLife{") 
              .append("simulationName='").append(getName()).append("', ") 
              .append("simulationTitle='").append(getTitle()).append("', ") 
              .append("simulationAuthor='").append(getAuthor()).append("', ") 
              .append("xSize='").append(getXSize()).append("', ") 
              .append("ySize='").append(getYSize()).append("'. ") 
              .append("percentTree='").append(getPercentTree()).append("', ") 
              .append("percentBurn='").append(getPercentBurn()).append("', ") 
              .append("percentEmpty='").append(getPercentEmpty()).append("', ") 
              .append("probCatch='").append(getProbCatch()).append("', ") 
              .append('}'); 
       return result.toString(); 
    } 
 

15 lines in XOXMLFactory, LifeXMLFactory, WaterXMLFactory


XOXMLFactory
/cellsociety_team01/src/xo/XOXMLFactory.java
LifeXMLFactory
/cellsociety_team01/src/life/LifeXMLFactory.java
WaterXMLFactory
/cellsociety_team01/src/water/WaterXMLFactory.java
    @Override 
    public Simulation getSimulation (Element root) throws XMLFactoryException { 
        if (! isValidFile(root)) { 
            throw new XMLFactoryException("XML file does not represent a %s", getSimulationType()); 
        } 
        // BUGBUG: hard coding tagNames is a bad idea 
        String simulationName = getTextValue(root, "simulation_name"); 
        String simulationTitle = getTextValue(root, "simulation_title"); 
        String simulationAuthor = getTextValue(root, "simulation_author"); 
        String xGridSize = getTextValue(root, "XGridSize"); 
        String yGridSize = getTextValue(root, "YGridSize"); 
        String X = getTextValue(root, "percentX"); 
        String O = getTextValue(root, "percentO"); 
        return new XOXML(simulationName, simulationTitle, simulationAuthor, xGridSize, yGridSize, XO); 
    } 
    @Override 
    public Simulation getSimulation (Element root) throws XMLFactoryException { 
        if (! isValidFile(root)) { 
            throw new XMLFactoryException("XML file does not represent a %s", getSimulationType()); 
        } 
        // BUGBUG: hard coding tagNames is a bad idea 
        String simulationName = getTextValue(root, "simulation_name"); 
        String simulationTitle = getTextValue(root, "simulation_title"); 
        String simulationAuthor = getTextValue(root, "simulation_author"); 
        String xGridSize = getTextValue(root, "XGridSize"); 
        String yGridSize = getTextValue(root, "YGridSize"); 
        String Alive = getTextValue(root, "percentAlive"); 
        String Dead = getTextValue(root, "percentDead"); 
        return new LifeXML(simulationName, simulationTitle, simulationAuthor, xGridSize, yGridSize, AliveDead); 
    } 
    @Override 
    public Simulation getSimulation (Element root) throws XMLFactoryException { 
        if (! isValidFile(root)) { 
            throw new XMLFactoryException("XML file does not represent a %s", getSimulationType()); 
        } 
        // BUGBUG: hard coding tagNames is a bad idea 
        String simulationName = getTextValue(root, "simulation_name"); 
        String simulationTitle = getTextValue(root, "simulation_title"); 
        String simulationAuthor = getTextValue(root, "simulation_author"); 
        String xGridSize = getTextValue(root, "XGridSize"); 
        String yGridSize = getTextValue(root, "YGridSize"); 
        String Fish = getTextValue(root, "percentFish"); 
        String Shark = getTextValue(root, "percentShark"); 
        return new LifeXML(simulationName, simulationTitle, simulationAuthor, xGridSize, yGridSize, FishShark); 
    } 
9/29/16 10:56 AM Powered by CodePro Server