⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 utility.java

📁 Svm based face detector code
💻 JAVA
字号:

/**
 * Utility class. Contains functions used accross the board.
 * @author sanshack
 *
 */
public class Utility {
	/**
	 * Counts number of instances of x present in position
	 * @param position
	 * @param x
	 * @return number of instances of x present in position
	 */
	public static int countChar(String position,char x) {
		int length = position.length();
		char[] charArray = new char[23];
		charArray = position.toCharArray();
		int count =0;
		for(int i=0;i<23;i++) {
			if(charArray[i]==x) {
				count++;
			}
		}
		return count;
	}
	
	/**
	 * Switches black and white pieces in a board
	 * @param position
	 * @return Flipped board position
	 */
	
	public static String reverseColors(String position) {
		//System.out.println("initial="+position);
		String reverse = position;
		String temp1=reverse.replaceAll("W", "C");
		String temp2=temp1.replaceAll("B", "W");
		String temp3=temp2.replaceAll("C", "B");
		//System.out.println("reverse="+temp3);
		return temp3;
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -