Sha256: 9f5105fa0d419a9a9742a77baf2ce37eb21bef6023a7ba1d4107d019b122a7db
Contents?: true
Size: 620 Bytes
Versions: 2
Compression:
Stored size: 620 Bytes
Contents
class Strategy def execute raise NotImplementedError, 'Определён в наследниках' end end class Strategy1 < Strategy def execute puts 'Doing Strategy1...' end end class Strategy2 < Strategy def execute puts 'Doing Strategy2...' end end class Context attr_accessor :strategy def initialize(strategy) self.strategy=strategy end def execute_strategy strategy.execute end end strategy1 = Strategy1.new context = Context.new(strategy1) context.execute_strategy strategy2 = Strategy2.new context.strategy = strategy2 context.execute_strategy
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
mc_gem-0.0.1 | Lab2/examples/Strategy.rb |
mvcStudentXD-1.2.1 | Lab2/examples/Strategy.rb |