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| |
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| |
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 dip_2 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var bakery = new Restaurant("Bakery", new Oven()); | |
bakery.Cook("cookies"); |
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 dip_1 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var bakery = new Restaurant("Bakery"); | |
bakery.Cook("cookies"); |
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 Approximation Utilities | |
function ImplementationError(message) { | |
this.name = "ImplementationError"; | |
this.message = message; | |
} | |
ImplementationError.prototype = new Error(); | |
function createWithInterfaceValidation(prototypeObject, interfaceObject) { | |
Object.keys(interfaceObject).forEach(function(key) { | |
if (prototypeObject[key] === null || typeof prototypeObject[key] !== "function") { |
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
// Monster Types and Manager | |
var MonsterManager = { | |
init: function(monsters, locations) { | |
this.monsters = monsters; | |
this.locations = locations; | |
}, | |
getRandomLocation: function() { | |
function getRandomInt(max) { | |
return Math.floor(Math.random() * Math.floor(max)); |
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
function announce(collection) { | |
console.log(collection.description); | |
collection.logItems(); | |
} | |
var favoriteCities = { | |
items: { | |
"Denmark": "Copenhagen", | |
"Uganda": "Kampala", |
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
function announce(collection) { | |
console.log(collection.description); | |
collection.items.forEach(function(element) { | |
console.log(element); | |
}); | |
} | |
var favoriteCities = { | |
items: { |
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
function announce(collection) { | |
console.log(collection.description); | |
collection.items.forEach(function(element) { | |
console.log(element); | |
}); | |
} | |
var favoriteCities = { | |
items: ["Copenhagen", "Kampala", "Montevideo"], |
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 SpaceStation | |
attr_reader :sensors, :supply_hold, :supply_reporter, | |
:fuel_tank, :fuel_reporter, :thrusters | |
def initialize | |
@sensors = Sensors.new | |
@supply_hold = SupplyHold.new | |
@supply_reporter = SupplyReporter.new(@supply_hold) | |
@fuel_tank = FuelTank.new | |
@fuel_reporter = FuelReporter.new(@fuel_tank) |