Foibs

attacks arxh me antikeimenostrefeia

Dec 19th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.68 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp2
  4. {
  5.     class Program
  6.     {
  7.         static void Main()
  8.         {
  9.             Item[] Inventory = new Item[5];
  10.             Weapon BabyDevastator = new Weapon("Baby Devastator", 99);
  11.             Armor ThiccWaifu = new Armor("Noice", 10);
  12.             Weapon Edging = new Weapon("Edging", 5);
  13.  
  14.             Inventory[0] = BabyDevastator;
  15.             Inventory[1] = ThiccWaifu;
  16.             Inventory[2] = Edging;
  17.  
  18.             for(int i = 0; i< Inventory.Length; i++)
  19.             {
  20.                 if(Inventory[i] is Weapon)
  21.                 {
  22.                     Console.WriteLine(Inventory[i].GetName());
  23.                 }
  24.             }
  25.         }
  26.     }
  27.     class Item
  28.     {
  29.         protected string name;
  30.  
  31.         public string GetName()
  32.         {
  33.             return name;
  34.         }
  35.     }
  36.     class Weapon : Item
  37.     {
  38.         double statMod;
  39.  
  40.         public Weapon(string wName, double wStatMod)
  41.         {
  42.             name = wName;
  43.             statMod = wStatMod;
  44.         }
  45.         public double GetStatMod()
  46.         {
  47.             return statMod;
  48.         }
  49.     }
  50.     class Armor : Item
  51.     {
  52.         double statMod;
  53.         public Armor(string aName, double aStatMod)
  54.         {
  55.             name = aName;
  56.             statMod = aStatMod;
  57.         }
  58.         public double GetStatMod()
  59.         {
  60.             return statMod;
  61.         }
  62.     }
  63.     class Potion : Item
  64.     {
  65.         double statMod;
  66.         public Potion(string pName, double pStatMod)
  67.         {
  68.             name = pName;
  69.             statMod = pStatMod;
  70.         }
  71.         public double GetStatMod()
  72.         {
  73.             return statMod;
  74.         }
  75.     }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment