RavidEliyahu / RPGDecorator

Decorator Example ✨

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RPGDecorator

decorator
This example allow the client to create a character from one of 3 races (Men, Elfs, Dwarves).
In addition you can give it one class or many (Archer, Wizard, Warrior) no matter the order of applience.
For Example:

ICharacter a = new Warrior(new Archer(new Men()));
ICharacter b = new Archer(new Warrior(new Men()));

a and b have the same functionallity, power & race.

Another Example:

ICharacter character = new Wizard(new Warrior(new Archer(new Elf())));

Now this one above has the greatest power among Elfs because he is wrapped with all of the concrete decorators.

Structure

Componenet:

  • ICharacter

Base Decorator:

  • Decorator

Concrete Components:

  • Men
  • Elf
  • Dwarf

Concrete Decorators:

  • Archer
  • Wizard
  • Warrior

Untitled Workspace (4) Influenced by: refactoring.guru

About

Decorator Example ✨

License:MIT License


Languages

Language:C# 100.0%