Garloon

5.3

Sep 9th, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.01 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 CSLight
  8. {
  9.     class Menu
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Console.WriteLine("\nВведите координаты расположения персонажа");
  14.             Console.Write("По вертикали(0...10): ");
  15.             int _posX = Convert.ToInt32(Console.ReadLine());
  16.             Console.Write("По горизонтали(0...10): ");
  17.             int _posY = Convert.ToInt32(Console.ReadLine());
  18.             Character character = new Character();
  19.             character.CreateCharacter(_posX, _posY);
  20.         }
  21.     }
  22.  
  23.     class Character
  24.     {
  25.         private int _x;
  26.         private int _y;
  27.  
  28.         public int posX
  29.         {
  30.             get
  31.             {
  32.                 return _x;
  33.             }
  34.             set
  35.             {
  36.                 if(value >= 0 && value <= 10)
  37.                 {
  38.                     _x = value;
  39.                 }
  40.             }
  41.         }
  42.         public int posY
  43.         {
  44.             get
  45.             {
  46.                 return _y;
  47.             }
  48.             set
  49.             {
  50.                 if (value >= 0 && value <= 10)
  51.                 {
  52.                     _y = value;
  53.                 }
  54.             }
  55.         }
  56.  
  57.         public char[,] Appearance =
  58.         {
  59.                 {' ', '0', ' '},
  60.                 {'-', '|', '-'},
  61.                 {'/', ' ', 'L'},
  62.         };
  63.         public void CreateCharacter(int posx, int posy)
  64.         {
  65.             Console.Clear();
  66.             Console.SetCursorPosition(posx, posy);
  67.             for (int i = 0; i < Appearance.GetLength(0); i++)
  68.             {
  69.                 for (int j = 0; j < Appearance.GetLength(1); j++)
  70.                 {
  71.                     Console.Write(Appearance[i, j]);
  72.                 }
  73.                 Console.WriteLine();
  74.                 Console.SetCursorPosition(posx, ++posy);
  75.             }
  76.         }
  77.     }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment