Advertisement
Guest User

Untitled

a guest
Nov 30th, 2015
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.82 KB | None | 0 0
  1. using System;
  2. using System.Net;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Timers;
  8.  
  9. namespace ConsoleApplication3
  10. {
  11. class MyAnimal
  12. {
  13.  
  14. static Timer timer = new Timer(2000);
  15. static Timer timer2 = new Timer(6000);
  16. static int i = 10;
  17. static int i2 = 20;
  18. static bool IsDead = false;
  19. string Happiness = i.ToString();
  20. string name = "Jumbo";
  21. int Age = 6;
  22.  
  23. public void printinfo ()
  24. {
  25. timer.Elapsed += timer_Elapsed;
  26. timer2.Elapsed += timer_Elapsed2;
  27. timer.Start();
  28. timer2.Start();
  29. Start:
  30. Console.Write("Your pet's name is : " + name);
  31. Console.Write("\nYour pet's age is : " + Age);
  32. Console.Write("\nYour pet's happiness is : " + i.ToString());
  33. Console.Write("\nYour pet's hunger is : " + i2.ToString());
  34. Console.WriteLine("\n1 - Feed | 2 - Play a game ");
  35. int Choosed;
  36. string lines = Console.ReadLine();
  37. if(lines == "")
  38. {
  39. Console.Clear();
  40. Console.WriteLine("Error 404 !");
  41. Console.WriteLine("");
  42. Console.WriteLine("");
  43. goto Start;
  44. }
  45. Choosed = Convert.ToInt32(lines);
  46. if(IsDead == true)
  47. {
  48. return;
  49. }
  50. if (Choosed == 0 || Choosed > 2)
  51. {
  52. Console.Clear();
  53. Console.WriteLine("Error 404 !");
  54. Console.WriteLine("");
  55. Console.WriteLine("");
  56. goto Start;
  57. }
  58. if (Choosed == 1)
  59. {
  60. Console.Clear();
  61. Console.WriteLine("You chose to feed your pet !");
  62. Console.WriteLine("");
  63. Console.WriteLine("");
  64. i2 = 20;
  65. goto Start;
  66. }
  67. if (Choosed == 2)
  68. {
  69. Console.Clear();
  70. Console.WriteLine("You chose to play with your pet !");
  71. Console.WriteLine("");
  72. Console.WriteLine("");
  73. i = 10;
  74. goto Start;
  75. }
  76. }
  77. private static void timer_Elapsed(object sender, ElapsedEventArgs e)
  78. {
  79. string name = "Jumbo";
  80. int Age = 6;
  81. Console.Clear();
  82. i2--;
  83. if (i2 == 0)
  84. {
  85. IsDead = true;
  86. timer.Stop();
  87. timer2.Stop();
  88. Console.Clear();
  89. Console.WriteLine("\nYour pet died from hunger.. :/");
  90. return;
  91. }
  92.  
  93. Console.Write("Your pet's name is : " + name);
  94. Console.Write("\nYour pet's age is : " + Age);
  95. Console.Write("\nYour pet's happiness is : " + i.ToString());
  96. Console.Write("\nYour pet's hunger is : " + i2.ToString());
  97. Console.WriteLine("\n1 - Feed | 2 - Play a game ");
  98. GC.Collect();
  99. }
  100. private static void timer_Elapsed2(object sender, ElapsedEventArgs e)
  101. {
  102. i--;
  103. if (i == 0)
  104. {
  105. IsDead = true;
  106. timer.Stop();
  107. timer2.Stop();
  108. Console.Clear();
  109. Console.WriteLine("\nYour pet died of boredom.. :/");
  110. return;
  111. }
  112.  
  113. GC.Collect();
  114. }
  115. }
  116. class Program
  117. {
  118. static void Main(string[] args)
  119. {
  120.  
  121. MyAnimal mydog = new MyAnimal();
  122. mydog.printinfo();
  123. Console.ReadKey();
  124.  
  125. }
  126. }
  127. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement