Skip to content

Instantly share code, notes, and snippets.

@sevperez
Created October 1, 2018 17:52
Show Gist options
  • Save sevperez/8ef7ea601b2cf4cc844b5aa9fb6041ec to your computer and use it in GitHub Desktop.
Save sevperez/8ef7ea601b2cf4cc844b5aa9fb6041ec to your computer and use it in GitHub Desktop.
using System;
namespace dip_1
{
class Program
{
static void Main(string[] args)
{
var bakery = new Restaurant("Bakery");
bakery.Cook("cookies");
}
}
class Restaurant
{
public string Name { get; set; }
private Oven Oven = new Oven();
public Restaurant(string name)
{
this.Name = name;
}
public void Cook(string item)
{
this.Oven.LightGas();
this.Oven.Bake(item);
this.Oven.ExtinguishGas();
}
}
class Oven
{
public bool On { get; set; }
public void LightGas()
{
Console.WriteLine("Lighting the oven's gas!");
this.On = true;
}
public void ExtinguishGas()
{
Console.WriteLine("Extinguishing the oven's gas!");
this.On = false;
}
public void Bake(string item)
{
if (!this.On)
{
Console.WriteLine("Oven's gas is not turned on.");
}
else
{
Console.WriteLine("Now baking " + item + "!");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment