Similar Code Analysis Report

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

Table of contents

number of lines number of occurrences names of resources
7 2 Segregation
16 2 PredPrey
11 2 PredPrey
8..7 2 SpreadingOfFire, Segregation
4 2 PredPrey
8 4 PredPrey, SpreadingOfFire, Segregation, GameOfLife
3 4 PredPrey, SpreadingOfFire, Segregation, GameOfLife
11 3 SpreadingOfFire, Segregation, GameOfLife
41..40 2 FireXMLFactory, SegregationXMLFactory
21 2 PredPreyXMLFactory, GameOfLifeXMLFactory
8 2 PredPreyXMLFactory, GameOfLifeXMLFactory
2 2 PredPrey
5 3 MainXML
2 2 PredPrey
8 2 SegregationModel, FireModel
4 2 Main, GUIController
3 4 PredPrey, SpreadingOfFire, Segregation, GameOfLife
4 2 Segregation
11..10 2 PredPrey
3..2 2 SimulationManager
4 2 State
1 4 SpreadingOfFire

List of matches

 

16 lines in PredPrey (x2)


PredPrey
/cellsociety_team12/src/Simulations/PredPrey.java
PredPrey
/cellsociety_team12/src/Simulations/PredPrey.java
         emptyLoc.add(r+1); 
         emptyLoc.add(c); 
      } 
      if (checkOnGrid(r,c+1) && ((myGrid[r][c+1].getNextState() == null) || (myGrid[r][c+1].getNextState().getStateID() == EMPTY))) { 
         emptyLoc.add(r); 
         emptyLoc.add(c+1); 
      } 
      if (checkOnGrid(r-1,c) && ((myGrid[r-1][c].getNextState() == null) || (myGrid[r-1][c].getNextState().getStateID() == EMPTY))) { 
         emptyLoc.add(r-1); 
         emptyLoc.add(c); 
      } 
      if (checkOnGrid(r,c-1) && ((myGrid[r][c-1].getNextState() == null) || (myGrid[r][c-1].getNextState().getStateID() == EMPTY))) { 
         emptyLoc.add(r); 
         emptyLoc.add(c-1); 
      } 
      return emptyLoc
         stateLoc.add(r+1); 
         stateLoc.add(c); 
      } 
      if (checkOnGrid(r,c+1) && (myGrid[r][c+1].getCellCurrentState().getStateID() == stateID)) { 
         stateLoc.add(r); 
         stateLoc.add(c+1); 
      } 
      if (checkOnGrid(r-1,c) && (myGrid[r-1][c].getCellCurrentState().getStateID() == stateID)) { 
         stateLoc.add(r-1); 
         stateLoc.add(c); 
      } 
      if (checkOnGrid(r,c-1) && (myGrid[r][c-1].getCellCurrentState().getStateID() == stateID)) { 
         stateLoc.add(r); 
         stateLoc.add(c-1); 
      } 
      return stateLoc
 

8 lines in PredPrey, SpreadingOfFire, Segregation, GameOfLife


SpreadingOfFire
/cellsociety_team12/src/Simulations/SpreadingOfFire.java
PredPrey
/cellsociety_team12/src/Simulations/PredPrey.java
GameOfLife
/cellsociety_team12/src/Simulations/GameOfLife.java
Segregation
/cellsociety_team12/src/Simulations/Segregation.java
   public void printGrid(){ 
      for (int i = 0; i < myGrid.length;i++){ 
         System.out.println(); 
         for(int j = 0 ; j<myGrid[i].length; j++){ 
            System.out.print(myGrid[i][j].getCellCurrentState().getStateID()); 
         } 
      } 
   } 
   public void printGrid(){ 
      for (int i = 0; i < myGrid.length;i++){ 
         System.out.println(); 
         for(int j = 0 ; j<myGrid[i].length; j++){ 
            System.out.print(myGrid[i][j].getCellCurrentState().getStateID()); 
         } 
      } 
   } 
   public void printGrid(){ 
      for (int i = 0; i < myGrid.length;i++){ 
         System.out.println(); 
         for(int j = 0 ; j<myGrid[i].length; j++){ 
            System.out.print(myGrid[i][j].getCellCurrentState().getStateID()); 
         } 
      } 
   } 
   public void printGrid(){ 
      for (int i = 0; i < myGrid.length;i++){ 
         System.out.println(); 
         for(int j = 0 ; j<myGrid[i].length; j++){ 
            System.out.print(myGrid[i][j].getCellCurrentState().getStateID()); 
         } 
      } 
   } 
 

11 lines in SpreadingOfFire, Segregation, GameOfLife


Segregation
/cellsociety_team12/src/Simulations/Segregation.java
GameOfLife
/cellsociety_team12/src/Simulations/GameOfLife.java
SpreadingOfFire
/cellsociety_team12/src/Simulations/SpreadingOfFire.java
   private void updateCells(){ 
      for (int row = 0; row<myGrid.length; row++){ 
         for(int column = 0; column<myGrid[row].length; column++){ 
            if(myGrid[row][column].getNextState() != null){ 
               myGrid[row][column].setCellCurrentState(myGrid[row][column].getNextState()); 
               myGrid[row][column].setNextState(null); 
               //Give GUI row & column 
            } 
         } 
      } 
   } 
   private void updateCells(){ 
      for (int row = 0; row<myGrid.length; row++){ 
         for(int column = 0; column<myGrid[row].length; column++){ 
            if(myGrid[row][column].getNextState() != null){ 
               myGrid[row][column].setCellCurrentState(myGrid[row][column].getNextState()); 
               myGrid[row][column].setNextState(null); 
               //Give GUI row & column 
            } 
         } 
      } 
   } 
   private void updateCells(){ 
      for (int row = 0; row<myGrid.length; row++){ 
         for(int column = 0; column<myGrid[row].length; column++){ 
            if(myGrid[row][column].getNextState() != null){ 
               myGrid[row][column].setCellCurrentState(myGrid[row][column].getNextState()); 
               myGrid[row][column].setNextState(null); 
               //Give GUI row & column 
            } 
         } 
      } 
   } 
 

40..41 lines in FireXMLFactory, SegregationXMLFactory


SegregationXMLFactory
/cellsociety_team12/src/xml/factory/SegregationXMLFactory.java
FireXMLFactory
/cellsociety_team12/src/xml/factory/FireXMLFactory.java
    @Override 
    public SegregationModel getSim (Element root) throws XMLFactoryException {   
       if (! isValidFile(root)) { 
            throw new XMLFactoryException("XML file does not represent a %s", getSimType()); 
        } 
        
       String simName = null; 
       String simAuthor = null; 
       String simWidth = null; 
       String simHeight = null; 
        
       //get genparams 
       NodeList genpList = root.getElementsByTagName("genparam"); 
       Node genpNode = genpList.item(0); 
       if (genpNode.getNodeType() == Node.ELEMENT_NODE) { 
          Element genpElement = (Element) genpNode;  
          simName = getTextValue(genpElement, "simname"); 
          simAuthor = getTextValue(genpElement, "simauthor"); 
          simWidth = getTextValue(genpElement, "simwidth"); 
          simHeight = getTextValue(genpElement, "simheight"); 
       } 
        
       //get satisfaction 
       String satisfaction = getTextValue(root, "satisfaction"); 
        
       //create GenState objects 
       NodeList nList = root.getElementsByTagName("state"); 
       GenState[] states = new GenState[nList.getLength()]; 
        
       for (int temp = 0; temp < nList.getLength(); temp++) { 
          Node nNode = nList.item(temp); 
          if (nNode.getNodeType() == Node.ELEMENT_NODE) { 
             Element eElement = (Element) nNode; 
             states[temp] = new GenState(getTextValue(eElement, "statename"), getTextValue(eElement, "statecolor"), 
                   getTextValue(eElement, "percentage"), eElement.getAttribute("id")); 
          } 
       }     
         
        return new SegregationModel(simName, simAuthor, simWidth, simHeight, satisfaction, states[0], states[1], states[2]); 
    } 
    @Override 
    public FireModel getSim (Element root) throws XMLFactoryException {   
       if (! isValidFile(root)) { 
            throw new XMLFactoryException("XML file does not represent a %s", getSimType()); 
        } 
        
       String simName = null; 
       String simAuthor = null; 
       String simWidth = null; 
       String simHeight = null; 
        
       //get genparams 
       NodeList genpList = root.getElementsByTagName("genparam"); 
       Node genpNode = genpList.item(0); 
       if (genpNode.getNodeType() == Node.ELEMENT_NODE) { 
          Element genpElement = (Element) genpNode;  
          simName = getTextValue(genpElement, "simname"); 
          simAuthor = getTextValue(genpElement, "simauthor"); 
          simWidth = getTextValue(genpElement, "simwidth"); 
          simHeight = getTextValue(genpElement, "simheight"); 
       } 
        
       //get probcatch 
       String probCatch = getTextValue(root, "probcatch"); 
        
        
       //create GenState objects 
       NodeList nList = root.getElementsByTagName("state"); 
       GenState[] states = new GenState[nList.getLength()]; 
        
       for (int temp = 0; temp < nList.getLength(); temp++) { 
          Node nNode = nList.item(temp); 
          if (nNode.getNodeType() == Node.ELEMENT_NODE) { 
             Element eElement = (Element) nNode; 
             states[temp] = new GenState(getTextValue(eElement, "statename"), getTextValue(eElement, "statecolor"), 
                   getTextValue(eElement, "percentage"), eElement.getAttribute("id")); 
          } 
       }     
         
        return new FireModel(simName, simAuthor, simWidth, simHeight, probCatch, states[0], states[1], states[2]); 
    } 
 

21 lines in PredPreyXMLFactory, GameOfLifeXMLFactory


GameOfLifeXMLFactory
/cellsociety_team12/src/xml/factory/GameOfLifeXMLFactory.java
PredPreyXMLFactory
/cellsociety_team12/src/xml/factory/PredPreyXMLFactory.java
    @Override 
    public GameOfLifeModel getSim (Element root) throws XMLFactoryException {   
       if (! isValidFile(root)) { 
            throw new XMLFactoryException("XML file does not represent a %s", getSimType()); 
        } 
        
       String simName = null; 
       String simAuthor = null; 
       String simWidth = null; 
       String simHeight = null; 
        
       //get genparams 
       NodeList genpList = root.getElementsByTagName("genparam"); 
       Node genpNode = genpList.item(0); 
       if (genpNode.getNodeType() == Node.ELEMENT_NODE) { 
          Element genpElement = (Element) genpNode;  
          simName = getTextValue(genpElement, "simname"); 
          simAuthor = getTextValue(genpElement, "simauthor"); 
          simWidth = getTextValue(genpElement, "simwidth"); 
          simHeight = getTextValue(genpElement, "simheight"); 
       } 
    @Override 
    public PredPreyModel getSim (Element root) throws XMLFactoryException {   
       if (! isValidFile(root)) { 
            throw new XMLFactoryException("XML file does not represent a %s", getSimType()); 
        } 
        
       String simName = null; 
       String simAuthor = null; 
       String simWidth = null; 
       String simHeight = null; 
        
       //get genparams 
       NodeList genpList = root.getElementsByTagName("genparam"); 
       Node genpNode = genpList.item(0); 
       if (genpNode.getNodeType() == Node.ELEMENT_NODE) { 
          Element genpElement = (Element) genpNode;  
          simName = getTextValue(genpElement, "simname"); 
          simAuthor = getTextValue(genpElement, "simauthor"); 
          simWidth = getTextValue(genpElement, "simwidth"); 
          simHeight = getTextValue(genpElement, "simheight"); 
       } 
9/29/16 2:19 PM Powered by CodePro Server