Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 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 ConsoleApp2
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. Console.WriteLine("Welcome");
  14. Hero Judas = new Hero("Judas", 120, 10);
  15. Hero Cain = new Hero("Cain", 140, 10);
  16.  
  17. while (true)
  18. {
  19. int JudasAttack = Judas.Attack();
  20. Cain.takeDamage(JudasAttack);
  21. if (!Cain.isAlive())
  22. {
  23. Console.WriteLine("Judas Wins");
  24. break;
  25. }
  26.  
  27. int CainAttack = Cain.Attack();
  28. Judas.takeDamage(CainAttack);
  29. if (!Judas.isAlive())
  30. {
  31. Console.WriteLine("Cain Wins");
  32. break;
  33. }
  34. }
  35.  
  36. }
  37. }
  38. class Hero
  39. {
  40. public string name;
  41. public int health;
  42. public int damage;
  43. public Hero(string nName, int nHealth, int nDamage)
  44. {
  45. name = nName;
  46. health = nHealth;
  47. damage = nDamage;
  48. }
  49. public int Attack()
  50. {
  51. return damage;
  52. }
  53. public void takeDamage(int damageTaken)
  54. {
  55. health = health - damageTaken;
  56. }
  57. public bool isAlive()
  58. {
  59. if(health > 0)
  60. {
  61. return true;
  62. }
  63. else
  64. {
  65. return false;
  66. }
  67. }
  68. }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement