Advertisement
dmitryEfremov

Untitled

Jun 7th, 2020
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. using System;
  2. namespace ConsoleApp11
  3. {
  4. class Program
  5. {
  6. static void Main(string[] args)
  7. {
  8. Player player = new Player(3, 0);
  9. player.Show();
  10. }
  11. }
  12.  
  13. class Player
  14. {
  15. private string player = "(*-*)";
  16. private int _x;
  17. private int _y;
  18.  
  19. public Player(int x, int y)
  20. {
  21. _x = x;
  22. _y = y;
  23. }
  24.  
  25. public int X
  26. {
  27. get
  28. {
  29. if (_x >= 3)
  30. {
  31. return _x;
  32. }
  33. else
  34. {
  35. Console.WriteLine("Вы ввели не правильно значение"); return 0;
  36. }
  37. }
  38. set
  39. {
  40. _x = value;
  41. }
  42. }
  43.  
  44. public int Y
  45. {
  46. get
  47. {
  48. return _y;
  49. }
  50. set
  51. {
  52. _y = value;
  53. }
  54. }
  55.  
  56. public void Show()
  57. {
  58. Console.ForegroundColor = ConsoleColor.Red;
  59. Console.SetCursorPosition(X-3,Y);
  60. Console.Write(player);
  61. Console.ForegroundColor = ConsoleColor.Gray;
  62. }
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement