Advertisement
Guest User

Untitled

a guest
Jan 21st, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.04 KB | None | 0 0
  1.  
  2. namespace ChallangeHeroMonsterClassesPart1
  3. {
  4.     public partial class Default : System.Web.UI.Page
  5.     {
  6.         protected void Page_Load(object sender, EventArgs e)
  7.         {
  8.             Dice dice1 = new Dice();
  9.             Dice dice2 = new Dice();
  10.  
  11.             Characters hero = new Characters();
  12.             Characters monster = new Characters();
  13.        
  14.             hero.Name = "Hero";
  15.             hero.Health = 20;
  16.             hero.AttackBonus = false;
  17.             hero.DamageMaximum = 20;
  18.            
  19.  
  20.             monster.Name = "Monster";
  21.             monster.Health = 20;
  22.             monster.AttackBonus = true;
  23.             monster.DamageMaximum = 20;
  24.  
  25.  
  26.  
  27.  
  28.  
  29.             monster.Defend(hero.Attack(dice1,hero));
  30.             hero.Defend(monster.Attack(dice2,monster));
  31.             int giverandom1 = dice1.Roll();
  32.             int giverandom2 = dice2.Roll();
  33.             showStats(hero);
  34.             showStats(monster);
  35.  
  36.  
  37.  
  38.         }
  39.         private void showStats(Characters character)
  40.         {
  41.           Label1.Text += string.Format("<p> Name: {0} - Health: {1} - DamageMaximum: {2} - AttackBonus: {3} </p>",
  42.            character.Name, character.Health, character.DamageMaximum, character.AttackBonus);
  43.         }
  44.  
  45.    
  46.     }
  47.  
  48.  
  49.  
  50.     class Characters
  51.     {
  52.    
  53.         //public Random random = new Random();
  54.         public string Name { get; set; }
  55.         public int Health { get; set; }
  56.         public int DamageMaximum { get; set; }
  57.         public bool AttackBonus { get; set; }
  58.         public int myDamage { get; set; }
  59.  
  60.         public int Attack(Dice damage,Characters charc)
  61.         {
  62.             damage.sides = charc.DamageMaximum;
  63.             return damage.Roll();
  64.         }
  65.         public void Defend(int damage)
  66.         {
  67.             this.Health -= damage;
  68.         }
  69.  
  70.     }
  71.     class Dice
  72.     {
  73.  
  74.         public Random random { get; set; }
  75.         public int sides { get; set; }
  76.  
  77.         public int Roll()
  78.         {
  79.        
  80.             return random.Next(sides);
  81.  
  82.         }
  83.  
  84.     }
  85.  
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement