Raw Creational Patterns

mail@pastecode.io avatar
unknown
ruby
2 years ago
2.0 kB
1
Indexable
Never
enum class PrimaryWeapon {
    Sword, 
    Axe,
    Bow,
    MagicBook
};

enum class SecondaryWeapon {
    ShortSword,
    Shield,
    Arrows,
    None
};

enum class Tools {
    Lockpick,
    Bandages,
    Adrenaline, 
    ManaPotion
};

struct StartingEquipment {
    PrimaryWeapon primaryWeapon;
    SecondaryWeapon secondaryWeapon;
    Tools tools;
};

class Barbarian {
  public:
    void setStrength(int a_strength) { strength = a_strength; }
    int getStrength() const { return strength; }
    
    void setDefence(int a_defence) { defence = a_defence; }
    int getDefence() const { return defence; }
    
    void setSpeed(int a_speed) { speed = a_speed; }
    int getSpeed() const { return speed; }
    
    void setIntelligence(int a_intelligence) { intelligence = a_intelligence; }
    int getIntelligence() const { return intelligence; }
    
    void setStartingEquipment(StartingEquipment a_startingEquipment) { startingEquipment = a_startingEquipment; } 
    StartingEquipment getStartingEquipment() const { return startingEquipment; };
  private:
    int strength;
    int defence;
    int speed;
    int intelligence;
    StartingEquipment startingEquipment;
};

class Magician {
  public:
    void setStrength(int a_strength) { strength = a_strength; }
    int getStrength() const { return strength; }
    
    void setDefence(int a_defence) { defence = a_defence; }
    int getDefence() const { return defence; }
    
    void setSpeed(int a_speed) { speed = a_speed; }
    int getSpeed() const { return speed; }
    
    void setIntelligence(int a_intelligence) { intelligence = a_intelligence; }
    int getIntelligence() const { return intelligence; }
    
    void setStartingEquipment(StartingEquipment a_startingEquipment) { startingEquipment = a_startingEquipment; } 
    StartingEquipment getStartingEquipment() const { return startingEquipment; };
  private:
    int strength;
    int defence;
    int speed;
    int intelligence;
    StartingEquipment startingEquipment;
};