COSTA: COSt and Termination Analyzer for Java Bytecode
    
    /*
 *  Copyright (C) 2009  E.Albert, P.Arenas, S.Genaim, G.Puebla, and D.Zanardini
 *                      https://costa.ls.fi.upm.es
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package pubs;
/**
 * A toy class for representing polynomials.
 * 
 * @author E.Albert, P.Arenas, S.Genaim, and G.Puebla
 *
 */
class Polynomial extends Data {

	protected int deg;
	protected int[] coefs;

	public Polynomial() {
		deg = 0;
		coefs = new int[11];
	}

	/**
	 * A method for copying polynomials. Note that no matter
	 * what the degree of the polynomial is, at most the first
	 * 10 coefficients are copied. Thus, a constant upper bound
	 * can be obtained.
	 */
	public Data copy() {
		Polynomial copy = new Polynomial();
		copy.deg = deg;
		for (int i = 0;(i <= deg && i <= 10);i++)
			copy.coefs[i] = coefs[i];
		return copy;
	}

	public static void main(String[] args) {

		// Prepare the test
		Polynomial test = new Polynomial();
		for (int i = 0; i < 11; i++) {
			test.coefs[i] = i;
		}
		test.deg = 12;

		// Test
		Data result = test.copy();
	}
}