Skip to content

Instantly share code, notes, and snippets.

@ppsdatta
Created December 8, 2022 08:36
Show Gist options
  • Save ppsdatta/a6b0815062a25aea8b782d4b227ea25f to your computer and use it in GitHub Desktop.
Save ppsdatta/a6b0815062a25aea8b782d4b227ea25f to your computer and use it in GitHub Desktop.
Live coding
using System;
using System.Collections.Generic;
namespace Console1
{
class Beverage
{}
class Flavor
{}
class Coffee
{}
class CoffeeMachine
{}
class Program
{
static void Main(string[] args)
{
var myCoffeeMachine = <Build a DEFAULT coffee machine>;
myCoffeeMachine.List();
/*
0 -> Cappuccino
1 -> Hot Water
2 -> Steam
*/
myCoffeeMachine
.Select(0)
.Select(2);
myCoffeeMachine.Make(); // Here is your drink - Cappuccino with Steam
myCoffeeMachine
.Select(0)
.Select(5)
.Select(1).Make(); // Here is your drink - Cappuccino with Hot Water
myCoffeeMachine
.Select(0);
myCoffeeMachine.Make(); // Here is your drink - Cappuccino
myCoffeeMachine.AddBeverage("Mocha");
myCoffeeMachine.List();
/*
0 -> Cappuccino
1 -> Hot Water
2 -> Steam
3 -> Mocha
*/
var myNewCoffeeMachine = <Build a new Coffee Machine with Espresso, Steam and Frappe as drinks>;
myNewCoffeeMachine.List();
/*
0 -> Espresso
1 -> Steam
2 -> Frappe
*/
myNewCoffeeMachine
.Select(0)
.Select(1);
myNewCoffeeMachine.Make(); // Here is your drink - Espresso with Steam
var anotherMachine = <Add code to make a Coffee Machine with DEFAULT 3 drinks + Green Tea and Caffe Mocha>;
anotherMachine.List();
/*
0 -> Cappuccino
1 -> Hot Water
2 -> Steam
3 -> Green Tea
4 -> Caffe Mocha
*/
anotherMachine
.Select(0)
.Select(3);
anotherMachine.Make(); // Here is your drink - Cappuccino with Green Tea
anotherMachine
.Select(0)
.Select(9);
anotherMachine.Make(); // Here is your drink - Cappuccino
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment