Skip to content

Instantly share code, notes, and snippets.

@ilyaBrandon
Created February 24, 2016 19:18
Show Gist options
  • Save ilyaBrandon/2f67b85db5eb413ba0e9 to your computer and use it in GitHub Desktop.
Save ilyaBrandon/2f67b85db5eb413ba0e9 to your computer and use it in GitHub Desktop.
public class BATTLEFRONT {
public static void main(String[] args) {
printCoordinates("a", "2");
printCoordinates("h", "8");
printCoordinates("c", "2");
}
static String getQuandrant(String v, String h){
String verticall="abcdefghi";
String horisontall="123456789";
int pixell=64;
int y=verticall.indexOf(v)*pixell;
int x=horisontall.indexOf(h)*pixell;
String result=y+"_"+x;
return result;
}
static void printCoordinates (String v, String h){
String result=getQuandrant(v, h);
String x=result.substring(0, result.indexOf("_"));
String y=result.substring(result.indexOf("_")+1);
System.out.println(v+h+":("+x+"px;"+y+"px)"); }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment