All Downloads are FREE. Search and download functionalities are using the official Maven repository.

model.MARK_II.util.Formatter Maven / Gradle / Ivy

The newest version!
package model.MARK_II.util;

import model.MARK_II.generalAlgorithm.ColumnPosition;
import java.util.Set;

/**
 * @author Quinn Liu ([email protected])
 * @version August 1, 2014
 */
public class Formatter {
    /**
     * @return Return the list of active column positions in the following
     * format: ((0, 0), (1, 1), (2, 2), (2,0))
     */
    public static String format(Set activeColumnPositions) {
        String listOfActiveColumns = "(";

        int numberOfActiveColumns = activeColumnPositions.size();
        for (ColumnPosition columnPosition : activeColumnPositions) {
            listOfActiveColumns += "(" + columnPosition.getRow() + ", " +
                    columnPosition.getColumn() + ")";
            --numberOfActiveColumns;

            if (numberOfActiveColumns == 0) {
                // this is the last active column so don't print ", "
            } else {
                listOfActiveColumns += ", ";
            }
        }

        listOfActiveColumns += ")";
        return listOfActiveColumns;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy