Similar Code Analysis Report

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

Table of contents

number of lines number of occurrences names of resources
9 2 Update
16..15 2 UpdatePredatorPrey
8..5 2 GUIGenerator
12..11 2 Update
23 2 GridIterator, Grid
8..7 2 UpdateSegregation, UpdateGameOfLife
4..3 2 Update, UpdatePredatorPrey
3 2 UpdateSegregation, UpdateGameOfLife
3 2 XmlMapper
3 2 GUIGenerator
3 2 GUIGenerator

List of matches

 

15..16 lines in UpdatePredatorPrey (x2)


UpdatePredatorPrey
/cellsociety_team22/src/engine/UpdatePredatorPrey.java
UpdatePredatorPrey
/cellsociety_team22/src/engine/UpdatePredatorPrey.java
   public Cell eat(Animal shark, boolean reproduce) { 
      ArrayList<Cell> neighbors = super.getImmediateNeighbors(shark); 
      ArrayList<Cell> fishCells = new ArrayList<Cell>(); 
      for(Cell neighbor : neighbors) { 
         if (neighbor.getCurrentState() == 1 && neighbor.getNextState() == 1) { 
            fishCells.add(neighbor); 
         } 
      } 
      if(fishCells.size() > 0) { 
         shark.setEnergy(shark.getEnergy() + 1); 
         int fishCellIndex = selectCell(fishCells); 
         Cell fishCell = grid.getCellList().get(fishCellIndex); 
         //System.out.println(shark.getNumber() + " ate " + fishCell.getNumber()); 
         swap(shark, (Animal) fishCell); //shark's next state is fishfish's next state is shark 
         if(reproduce) { 
   public Cell move(Cell cell, boolean reproduce) { 
      ArrayList<Cell> neighbors = super.getImmediateNeighbors(cell); 
      ArrayList<Cell> emptyCells = new ArrayList<Cell>(); 
      for(Cell neighbor : neighbors) { 
         if(neighbor.getCurrentState() == 0 && neighbor.getNextState() == 0) { 
            emptyCells.add(neighbor); 
         } 
      } 
      if (emptyCells.size() > 0) { 
         int emptyCellIndex = selectCell(emptyCells); 
         Cell emptyCell = grid.getCellList().get(emptyCellIndex); 
         if (cell.getCurrentState() == 1) { 
            //System.out.println(cell.getNumber() + " moved to " + emptyCell.getNumber()); 
         } 
         swap((Animal) cell, (Animal) emptyCell); //cell's next state is emptyempty cell's next state is fish/shark 
         if(reproduce) { 
 

23 lines in GridIterator, Grid


Grid
/cellsociety_team22/src/structures/Grid.java
GridIterator
/cellsociety_team22/src/structures/GridIterator.java
   @Override 
    public Iterator<Cell> iterator() { 
        Iterator<Cell> iterator = new Iterator<Cell>() { 
 
           private int currentIndex = 0; 
 
            @Override 
            public boolean hasNext() { 
               return currentIndex < getNumCells() && cellList.get(currentIndex) != null; 
            } 
 
            @Override 
            public Cell next() { 
                return cellList.get(currentIndex++); 
            } 
 
            @Override 
            public void remove() { 
                throw new UnsupportedOperationException(); 
            } 
        }; 
        return iterator
    } 
    @Override 
    public Iterator<Cell> iterator() { 
        Iterator<Cell> it = new Iterator<Cell>() { 
 
            private int currentIndex = 0; 
 
            @Override 
            public boolean hasNext() { 
                return currentIndex < currentSize && cellList.get(currentIndex) != null; 
            } 
 
            @Override 
            public Cell next() { 
                return cellList.get(currentIndex++); 
            } 
 
            @Override 
            public void remove() { 
                throw new UnsupportedOperationException(); 
            } 
        }; 
        return it
    } 
9/29/16 2:24 PM Powered by CodePro Server