TargeTPoweR

Работа со свойствами

Apr 7th, 2020
512
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 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 Tasks
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. Painter painter = new Painter();
  14. painter.PaintGamer();
  15. }
  16. }
  17.  
  18. class Gamer
  19. {
  20. public int Xposition { get; private set; }
  21. public int Yposition { get; private set; }
  22.  
  23. public Gamer(int x, int y)
  24. {
  25. Xposition = x;
  26. Yposition = y;
  27. }
  28. }
  29.  
  30. class Painter
  31. {
  32. private Gamer gamer = new Gamer(6, 6);
  33.  
  34. public void PaintGamer(char playerChar1 = 'O', char playerChar2 = '*', char playerChar3 = '_')
  35. {
  36. int XpositionForRendering = gamer.Xposition;
  37. int YpositionForRendering = gamer.Yposition;
  38. Console.SetCursorPosition(XpositionForRendering, YpositionForRendering);
  39. Console.Write(playerChar1);
  40. Console.SetCursorPosition(XpositionForRendering + 2, YpositionForRendering);
  41. Console.Write(playerChar1);
  42. Console.SetCursorPosition(XpositionForRendering + 1, YpositionForRendering + 1);
  43. Console.Write(playerChar2);
  44. Console.SetCursorPosition(XpositionForRendering, YpositionForRendering + 2);
  45. Console.Write(playerChar3);
  46. Console.SetCursorPosition(XpositionForRendering + 1, YpositionForRendering + 2);
  47. Console.Write(playerChar3);
  48. Console.SetCursorPosition(XpositionForRendering + 2, YpositionForRendering + 2);
  49. Console.Write(playerChar3);
  50. Console.CursorVisible = false;
  51. Console.ReadKey();
  52. }
  53. }
  54. }
Add Comment
Please, Sign In to add comment