Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp2
- {
- class Program
- {
- static void Main()
- {
- Item[] Inventory = new Item[5];
- Weapon BabyDevastator = new Weapon("Baby Devastator", 99);
- Armor ThiccWaifu = new Armor("Noice", 10);
- Weapon Edging = new Weapon("Edging", 5);
- Inventory[0] = BabyDevastator;
- Inventory[1] = ThiccWaifu;
- Inventory[2] = Edging;
- for(int i = 0; i< Inventory.Length; i++)
- {
- if(Inventory[i] is Weapon)
- {
- Console.WriteLine(Inventory[i].GetName());
- }
- }
- }
- }
- class Item
- {
- protected string name;
- public string GetName()
- {
- return name;
- }
- }
- class Weapon : Item
- {
- double statMod;
- public Weapon(string wName, double wStatMod)
- {
- name = wName;
- statMod = wStatMod;
- }
- public double GetStatMod()
- {
- return statMod;
- }
- }
- class Armor : Item
- {
- double statMod;
- public Armor(string aName, double aStatMod)
- {
- name = aName;
- statMod = aStatMod;
- }
- public double GetStatMod()
- {
- return statMod;
- }
- }
- class Potion : Item
- {
- double statMod;
- public Potion(string pName, double pStatMod)
- {
- name = pName;
- statMod = pStatMod;
- }
- public double GetStatMod()
- {
- return statMod;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment