Advertisement
Guest User

Untitled

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