Advertisement
Guest User

Untitled

a guest
Apr 25th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.46 KB | None | 0 0
  1. //using inheritance
  2. class Item //base item class
  3. {
  4.     string name;
  5.     string description;
  6. }
  7.  
  8. class UsableItem : Item //class that inherits from item and adds functionality to be Used
  9. {
  10.     public void UseItem()
  11.     {
  12.         //code for using the item
  13.     }
  14. }
  15.  
  16. //not using inheritance (flat)
  17. class Item
  18. {
  19.     string name;
  20.     string description;
  21.     bool usable;
  22.  
  23.     public void UseItem()
  24.     {
  25.         //code for using the item
  26.     }
  27.     //simpler because it's all contained inside one class
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement