using System; namespace Project { class Program { public static void Main() { World world = new World(10, 10); for (int y = 0; y < 10; y++) { for (int x = 0; x < 10; x++) Console.Write("{0} ", world.Get(x, y)); Console.WriteLine(); } Console.ReadKey(); } } class World { private int[,] world; public int Width { get; private set; } public int Height { get; private set; } public World(int width, int height, int defaultValue = 0) { world = new int[height, width]; Width = width; Height = height; for (int y = 0; y < height; y++) for (int x = 0; x < width; x++) Set(x, y, defaultValue); } public bool Check(int x, int y) { return x >= 0 && x < Width && y >= 0 && y < Height; } public int Get(int x, int y) { if (!Check(x, y)) throw new Exception($"Out of bounds (x: {x}, y: {y})"); return world[y, x]; } public int Set(int x, int y, int value) { if (!Check(x, y)) throw new Exception($"Out of bounds (x: {x}, y: {y})"); return world[y, x]; } } }