Last active
August 29, 2015 14:21
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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