Android Open Source - donatello-y-raphael Cellpath






From Project

Back to project page donatello-y-raphael.

License

The source code is released under:

MIT License

If you think the Android project donatello-y-raphael listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.example.ATracePath;
/*  w w w .  j a  v  a 2  s  .  c om*/
import android.graphics.Color;
import android.util.Log;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by yngvi on 5.9.2014.
 */
public class Cellpath {

    private ArrayList<Coordinate> m_path = new ArrayList<Coordinate>();

    public void append( Coordinate co ) {
        int idx = m_path.indexOf(  co );
        if ( idx >= 0 ) {
            for ( int i=m_path.size()-1; i > idx; --i ) {
                m_path.remove(i);
            }
        }
        else {
            m_path.add(co);
        }
    }

    public List<Coordinate> getCoordinates() {
        return m_path;
    }

    public void reset() {
        m_path.clear();
    }

    public boolean isEmpty() {
        return m_path.isEmpty();
    }

    @Override
    public String toString() {
        String str = "";
        for (int i = 0; i < m_path.size(); i++) {
            str += "   " + m_path.get(i);
        }
        return str;
    }

    public boolean findCoordinate(Coordinate co) {
        for (int i = 0; i < m_path.size(); i++) {
            if (co.equals(m_path.get(i))) {
                removeTail(i);
                return true;
            }
        }
        return false;
    }

    public int getColor() {
        if (m_path.size() > 0) {
            return m_path.get(0).getColor();
        }
        return Color.TRANSPARENT;
    }

    public void removeTail(int index) {
        m_path = new ArrayList<Coordinate>(m_path.subList(0, index));
    }

    public int pathSize() {
        return m_path.size();
    }
}




Java Source Code List

com.example.ATracePath.Board.java
com.example.ATracePath.Cellpath.java
com.example.ATracePath.Challenge.java
com.example.ATracePath.Coordinate.java
com.example.ATracePath.DbHelper.java
com.example.ATracePath.Global.java
com.example.ATracePath.LevelsActivity.java
com.example.ATracePath.MainActivity.java
com.example.ATracePath.MapsActivity.java
com.example.ATracePath.Pack.java
com.example.ATracePath.PlayActivity.java
com.example.ATracePath.ProgressAdapter.java
com.example.ATracePath.Puzzle.java
com.example.ATracePath.SettingsActivity.java