Created
November 12, 2024 12:49
-
-
Save solanoize/608593874b9b6cb9edba14b5e41ce305 to your computer and use it in GitHub Desktop.
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
| 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