import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class MapZone
{
private final static Map<Zone, ZoneCoords> cord_map = new ConcurrentHashMap<Zone, ZoneCoords>();
public static void main(String[] args)
{
create(new Zone(1, 1), new ZoneCoords(245, 727, 5424));
create(new Zone(1, 2), new ZoneCoords(340, 432, 1234));
Zone zone_1 = getZone(1, 1);
ZoneCoords cord_1 = cord_map.get(zone_1);
System.out.println("##x = " + cord_1.x + "; y = " + cord_1.y + "; z = " + cord_1.z);
Zone zone_2 = getZone(1, 2);
ZoneCoords cord_2 = cord_map.get(zone_2);
System.out.println("##x = " + cord_2.x + "; y = " + cord_2.y + "; z = " + cord_2.z);
}
private static Zone getZone(int id, int number)
{
for(Zone zone : cord_map.keySet())
{
if(zone.zone == id && zone.number == number)
return zone;
}
return null;
}
private static void create(Zone zone, ZoneCoords coords)
{
cord_map.put(zone, coords);
}
static class Zone
{
public int zone;
public int number;
Zone(int zone, int number)
{
this.zone = zone;
this.number = number;
}
}
static class ZoneCoords
{
public int x;
public int y;
public int z;
ZoneCoords(int x, int y, int z)
{
this.x = x;
this.y = y;
this.z = z;
}
}
}
Code: Java
Можно и так