?? utility.java
字號(hào):
/**
* 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;
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -