Created
October 1, 2018 17:52
-
-
Save sevperez/8ef7ea601b2cf4cc844b5aa9fb6041ec to your computer and use it in GitHub Desktop.
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"); | |
} | |
} | |
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