Advertisement
Guest User

Untitled

a guest
Jul 13th, 2014
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.83 KB | None | 0 0
  1. using System;
  2.  
  3. namespace EnderDeath
  4. {
  5.     class EnderCat : Entity
  6.     {
  7.         public void Meow()
  8.         {
  9.             Console.WriteLine("M. EOW.");
  10.         }
  11.        
  12.         public override void Damage(int dam)
  13.         {
  14.             base.Damage(dam);
  15.             Meow();
  16.         }
  17.  
  18.         public override void Kick()
  19.         {
  20.             Damage(1);
  21.         }
  22.     }
  23.    
  24.     class Entity
  25.     {
  26.         public int Health = 100;
  27.         public bool IsAlive = true;
  28.        
  29.         public virtual void Damage(int dam)
  30.         {
  31.             if(Health < 1)
  32.                 throw new RuntimeException("You cannot kill dead entities.");
  33.            
  34.             Health -= dam;
  35.            
  36.             if(Health < 0)
  37.             {
  38.                 Health = 0
  39.                 IsAlive = false;
  40.             }
  41.         }
  42.     }
  43.    
  44.     public class Program
  45.     {
  46.         public static void Main(string[] args)
  47.         {
  48.             EnderCat EvilKitteh = new EnderCat();
  49.             for(int i=100;i > 5;i++)
  50.             {
  51.                 EvilKitteh.Kick();
  52.             }
  53.             Console.WriteLine("Shaddap ya darn cat!");
  54.         }
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement