Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.62 KB | None | 0 0
  1. using System;
  2. using System.Diagnostics;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace ConsoleApplication6
  9. {
  10. class Test
  11. {
  12. static Random rnd = new Random();
  13. static int[] limints = { 51, 63, 75, 87, 101 };
  14.  
  15. public Test()
  16. {
  17. neptun = setNeptun();
  18. result = rnd.Next(0, 101);
  19. }
  20. private string neptun;
  21.  
  22. public string Neptun
  23. {
  24. get { return neptun; }
  25. set { neptun = value; }
  26. }
  27.  
  28. private int result;
  29.  
  30. public int Result
  31. {
  32. get { return result; }
  33. set { result = value; }
  34. }
  35. public Test(string neptun)
  36. {
  37. Neptun = neptun;
  38. Result = rnd.Next(0, 101);
  39.  
  40.  
  41. }
  42.  
  43. string setNeptun()
  44. {
  45. string s = "";
  46. for (int i = 0; i < 6; i++)
  47. {
  48. if (rnd.Next(0, 2) == 0)
  49. {
  50. s += (char)rnd.Next(65, 91); //casting of a number to make it a character (65 is the ASCII code of A and 91 is the ASCII of Z)
  51. }
  52. else
  53. {
  54. s += rnd.Next(0, 10);
  55. }
  56.  
  57. /* alternative:
  58. string s = "ABCDEFGHIJKLMNOPQRSTUWZ";
  59. string s1 = "";
  60. for ( int i = 0; i<6, i++)
  61. {
  62. s1 += s[rnd.Next(0, s.Length)];
  63. }*/
  64.  
  65.  
  66. }
  67. return s;
  68. }
  69. public bool succesful()
  70. {
  71. if (result < limints[0]) return false;
  72. return true;
  73. }
  74.  
  75. public string print()
  76. {
  77. return neptun + " " + result + " ";
  78. }
  79. }
  80. class Program
  81. {
  82. static void Main(string[] args)
  83. {
  84. int n = 10;
  85. Console.WriteLine("\nTask 1");
  86. Test[] testobject = new Test[n];
  87. for (int i = 0; i < n; i++)
  88. {
  89. testobject[i] = new Test();
  90. Console.WriteLine(testobject[i].print());
  91. }
  92. Console.WriteLine("\nTask 2");
  93. for (int i = 0; i < n; i++)
  94. {
  95. if (testobject[i].succesful()) Console.WriteLine(testobject[i].print());
  96. }
  97.  
  98. Console.WriteLine("\nTask 3: ");
  99. testobject[1].Result = 99;
  100. testobject
  101. int best = testobject[0].Result;
  102.  
  103.  
  104.  
  105. Console.ReadKey();
  106. }
  107. }
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement