import java.util.ArrayList;
import java.util.List;

public class Cesta implements Comparable<Cesta> {

	// Cesta je list Dzbanu (resp jejich stavu)
	private final List<Dzbany> cesta = new ArrayList<Dzbany>();
	
	// Zalozi novou cestu se zadanym  aMax, bMax a c
	public Cesta(int aMax, int bMax, int c) {
		cesta.add(new Dzbany(0, 0, aMax, bMax, c, 0));
	}
	
	// 
	public Cesta(List<Dzbany> novaCesta) {
		cesta.addAll(novaCesta);
	}
	
	// Prida dzbanstav
	public void add(Dzbany dzbany) {
		cesta.add(dzbany);
	}
	
	// Ubere dzbanstav
	public void remove(Dzbany dzbany) {
		cesta.remove(dzbany);
	}
	
	// Zjisti zda cesta obsahuje stejny stav dzbanu
	public boolean contains(Dzbany dzbany) {
		return cesta.contains(dzbany);
	}
	
	// Vezme posledni stav dzbanu
	public Dzbany last() {
		return cesta.get(cesta.size()-1);
	}
	
	//Zkopiruje duplikat aktualni cesty
	public Cesta duplikat() {
		return new Cesta(cesta);
	}

	// Vrati ktery ze dvou dzbanuje vetsi kvuli razeni v TreeSetu
	public int compareTo(Cesta arg0) {
		int rozdil = cesta.size() - arg0.cesta.size();
		if (rozdil == 0) {
			return System.identityHashCode(this)-System.identityHashCode(arg0); 
		}
		return rozdil;
	}

	// Vytiskne delku cesty + cestu
	public String toString() {
		return String.format("%3d ", new Object[] { new Integer(cesta.size()) }) + cesta.toString();
	}
}
