Skip to content

Instantly share code, notes, and snippets.

View sevperez's full-sized avatar

Severin Perez sevperez

View GitHub Profile
class Laboratory
attr_accessor :scientists
def initialize(scientists, experiments)
@scientists = scientists
@experiments = experiments
end
def run_all_experiments
@scientists.each do |scientist|
class Laboratory
attr_accessor :scientists
def initialize(scientists, experiments)
@scientists = scientists
@experiments = experiments
end
def run_all_experiments
@scientists.each do |scientist|
using System;
namespace dip_2
{
class Program
{
static void Main(string[] args)
{
var bakery = new Restaurant("Bakery", new Oven());
bakery.Cook("cookies");
using System;
namespace dip_1
{
class Program
{
static void Main(string[] args)
{
var bakery = new Restaurant("Bakery");
bakery.Cook("cookies");
// 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") {
@sevperez
sevperez / ocp1.js
Last active September 18, 2018 16:36
// 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));
function announce(collection) {
console.log(collection.description);
collection.logItems();
}
var favoriteCities = {
items: {
"Denmark": "Copenhagen",
"Uganda": "Kampala",
function announce(collection) {
console.log(collection.description);
collection.items.forEach(function(element) {
console.log(element);
});
}
var favoriteCities = {
items: {
function announce(collection) {
console.log(collection.description);
collection.items.forEach(function(element) {
console.log(element);
});
}
var favoriteCities = {
items: ["Copenhagen", "Kampala", "Montevideo"],
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)