Skip to content

Instantly share code, notes, and snippets.

@solanoize
Created November 12, 2024 12:49
Show Gist options
  • Select an option

  • Save solanoize/608593874b9b6cb9edba14b5e41ce305 to your computer and use it in GitHub Desktop.

Select an option

Save solanoize/608593874b9b6cb9edba14b5e41ce305 to your computer and use it in GitHub Desktop.
public class GameMap {
static String getCoordinateItem(int[][] maps, int itemCode) {
String koordinat = "";
for (int baris = 0; baris < maps.length; baris++) {
for (int kolom = 0; kolom < maps[baris].length; kolom++) {
if (maps[baris][kolom] == itemCode) {
koordinat += "B" + baris + "K" + kolom;
}
}
}
return koordinat;
}
public static void main(String[] args) {
int [][] maps1 = {
{78, 43, 65, 76, 78, 23},
{90, 34, 78, 42},
{4, 70, 86, 43},
};
int weapon = 70;
int armor = 78;
String koordinatWeapon = getCoordinateItem(maps1, weapon);
String koordinatArmor = getCoordinateItem(maps1, armor);
System.out.println("Koordinat Weapon => " + koordinatWeapon);
System.out.println("Koordinat Armor => " + koordinatArmor);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment