Skip to content

Instantly share code, notes, and snippets.

@agusmakmun
Last active August 29, 2015 14:21
Show Gist options
  • Save agusmakmun/319ca8f472c40ea2d271 to your computer and use it in GitHub Desktop.
Save agusmakmun/319ca8f472c40ea2d271 to your computer and use it in GitHub Desktop.
Ini adalah simple checker papan catur dengan menggunakan java programminr, methode input, contohnya: g7 > akan di check apakah hitam atau putih.
import java.util.Scanner;
/**
* Ini adalah simple checker papan catur dengan menggunakan java programming
* methode input, contohnya: g7 > akan di check apakah hitam atau putih.
* @author Agus Makmun (Summon Agus)
* @blog bloggersmart.net - python.web.id
* Thanks to: Gunawan Ariyanto
*/
public class PapanCatur {
public static void main (String [] args) {
Scanner scan;
scan = new Scanner(System.in); //boolan inputan user
System.out.print("Masukkan label kotak papan: ");
String x = scan.nextLine();
char h = x.charAt(0);
int a = Integer.valueOf(String.valueOf(""+x.charAt(1))); //Integer.valueOf.(""+x.charAt(1)); //Integer.valueOf.(String.valueOf(+x.charAt(1)));
if (h == 'a' || h == 'c' || h == 'e' || h == 'g' ) {
if (a%2 == 1) {
System.out.println("Kotak Hitam");
}
else {
System.out.println("Kotak Putih");
}
}
else {
if (a%2 == 1) {
System.out.println("Kotak Putih");
}
else {
System.out.println("Kotak Hitam");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment