Advertisement
Fiskmans

10x10 drawing grid 2.0

Sep 7th, 2015
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.57 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication1
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             //init
  14.            
  15.             bool c = true; char Change = ' '; char y = ' '; char x = ' ';string Schange;int posx = 0; int posy = 0;
  16.             char[][] board;
  17.  
  18.             board = new char[10][];
  19.             for (int n = 0; n < 10; n++)
  20.             {
  21.                 board[n] = new char[10];
  22.             }
  23.  
  24.  
  25.             //set all as blank
  26.             for (int ix = 0; ix < 10; ix++)
  27.             {
  28.                 for (int iy = 0; iy < 10; iy++)
  29.                 {
  30.                     board[ix][iy] = ' ';
  31.                 }
  32.             }
  33.  
  34.             //init end
  35.  
  36.  
  37.             while (true)
  38.             {
  39.  
  40.  
  41.  
  42.                 Console.WriteLine("  A B C D E F G H I J");
  43.                 char posY = 'A';
  44.                 for (int ix = 0; ix < 10; ix++)
  45.                 {
  46.                     Console.Write(posY);
  47.                     for (int iy = 0; iy < 10; iy++)
  48.                     {
  49.                         Console.Write(" " + board[ix][iy]);
  50.                     }
  51.                     Console.Write("\n");
  52.                     posY++;
  53.                 }
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.                 //select
  62.  
  63.                 Console.Write("x:");
  64.                 var Kx = Console.ReadKey();
  65.                 x = char.Parse(Kx.Key.ToString());
  66.                 Console.WriteLine("");
  67.  
  68.                 Console.Write("y:");
  69.                 var ky = Console.ReadKey();
  70.                 y = char.Parse(ky.Key.ToString());
  71.                 Console.WriteLine("");
  72.  
  73.  
  74.                 if(x - 'A' >= 0)
  75.                 {
  76.                     posx = x - 'A';
  77.                 }else if (x - 'a' >= 0)
  78.                 {
  79.                     posx = x - 'a';
  80.                 }
  81.  
  82.                 if (y - 'A' >= 0)
  83.                 {
  84.                     posy = y - 'A';
  85.                 } else if (y- 'a'>= 0)
  86.                 {
  87.                     posy = y - 'a';
  88.                 }
  89.  
  90.                 Console.Write("Vad ska den vara:");
  91.                 try
  92.                 {
  93.                     Change = char.Parse(Console.ReadLine());
  94.                 }
  95.                 catch (FormatException e)
  96.                 {
  97.                     Console.WriteLine("Fel format!");
  98.                     Change = board[posx][posy];
  99.                 }
  100.                
  101.                 board[posx][posy] = Change;
  102.                
  103.             }
  104.         }
  105.     }
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement