Advertisement
Guest User

MVC

a guest
Mar 20th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 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. using System.Text.RegularExpressions;
  7.  
  8. namespace GameMoreAndLess
  9. {
  10. class Controller
  11. {
  12. public Model TinyModel;
  13.  
  14. public Controller(){
  15. TinyModel = new Model();
  16. }
  17. public void ReadBound() {
  18.  
  19. string strToRead;
  20. string[] numbers;
  21. int _a, _b;
  22.  
  23. strToRead = Console.ReadLine();
  24.  
  25. while (Regex.IsMatch(strToRead, "([\\+\\-]?[0-9]+\\W[\\+\\-]?[0-9]+") == false)
  26. {
  27. View.WriteErrors("Неправильнный ввод. Повторите ввод чисел. Чисел должно быть два. Первое должно быть меньше второго.");
  28. strToRead = Console.ReadLine();
  29. }
  30.  
  31. numbers = strToRead.Split(' ');
  32. _a = Int32.Parse(numbers[0]);
  33. _b = Int32.Parse(numbers[1]);
  34.  
  35. if (_a > _b) View.WriteErrors("Ошибочный диапазон! Первое число должно быть меньше второго!");
  36.  
  37. TinyModel.a=_a;
  38. TinyModel.b=_b;
  39.  
  40. }
  41.  
  42.  
  43.  
  44. }
  45. }
  46. }
  47.  
  48.  
  49.  
  50. using System;
  51. using System.Collections.Generic;
  52. using System.Linq;
  53. using System.Text;
  54. using System.Threading.Tasks;
  55.  
  56. namespace GameMoreAndLess
  57. {
  58. class View
  59. {
  60. static void Main(string[] args)
  61. {
  62. Controller controller = new Controller();
  63. WriteMessage("Введите границы диапазона. Таким образом чтобы крайние числа были включены.");
  64. controller.ReadBound();
  65. controller.GuessNumber();
  66. }
  67.  
  68. public static void WriteMessage(string textMessage)
  69. {
  70. Console.WriteLine(textMessage);
  71. }
  72.  
  73.  
  74.  
  75. public static void WriteErrors(string textError) {
  76. Console.WriteLine("Error: "+textError);
  77. }
  78.  
  79. public void GuessNumber()
  80. {
  81.  
  82.  
  83. }
  84. }
  85. }
  86.  
  87.  
  88. using System;
  89. using System.Collections.Generic;
  90. using System.Linq;
  91. using System.Text;
  92. using System.Threading.Tasks;
  93.  
  94. namespace GameMoreAndLess
  95. {
  96. class Model
  97. {
  98. public int a;
  99. public int b;
  100. public int x;
  101. }
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement