Function.java 794 Bytes
package kernel.function;

import kernel.Cell;
import kernel.Formula;

import java.util.ArrayList;
import java.util.Iterator;

abstract public class Function extends Formula {

    protected ArrayList<Cell> listCells = new ArrayList<>();

    abstract public String getDevelopedFormula();

    abstract public String toString();

    abstract public Double eval();

    public Boolean createCycle(Cell cell) {
 
    	boolean cycle=false;
        if (!this.listCells.contains(cell)){
        	Iterator<Cell> it=listCells.iterator();
        	while (it.hasNext() &&!cycle){
        		if (it.next().containFormula()){
        			cycle=it.next().getFormula().createCycle(cell);
        		}
        	}
        	return cycle;
        	
        }
        else
        	return true;
    	
    	
    }
}