This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace decorator_1 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var msg = "I love C-sharp"; | |
var simpleMsg = new SimpleMessage(msg); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace decorator_0 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var msg = "I love C-sharp"; | |
var simpleMsg = new SimpleMessage(msg); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module RunStrategies | |
class RunStrategyInterface | |
def self.run(name) | |
raise "Run method has not been implemented!" | |
end | |
end | |
class Jog < RunStrategyInterface | |
def self.run(name) | |
puts "#{name} is now jogging at a comfortable pace." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Runner | |
attr_reader :name, :strategy | |
attr_writer :strategy | |
def initialize(name, strategy) | |
@name = name | |
@strategy = strategy | |
end | |
def run |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Runner | |
attr_reader :name | |
def initialize(name) | |
@name = name | |
end | |
def run | |
puts "#{@name} is now running." | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface IArithmetic | |
{ | |
int Add(int num1, int num2); | |
int Subtract(int num1, int num2); | |
int Multiply(int num1, int num2); | |
double Divide(int num1, int num2); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace isp_2 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var basicStudent = new BasicMathStudent(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace isp_1 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var basicStudent = new BasicMathStudent(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MadScientist < Scientist | |
def run_experiment(experiment) | |
if sabotage? | |
puts "#{name} is now sabotaging the #{experiment.title} experiment!" | |
else | |
puts "#{name} is now running the #{experiment.title} experiment." | |
end | |
end | |
private |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Laboratory | |
attr_accessor :scientists | |
def initialize(scientists, experiments) | |
@scientists = scientists | |
@experiments = experiments | |
end | |
def run_all_experiments | |
@scientists.each do |scientist| |