Skip to content

RavidEliyahu/RPGDecorator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

Releases

No releases published

Packages

No packages published

Languages