Skip to content

Instantly share code, notes, and snippets.

@epalm
Created November 8, 2012 21:38
Show Gist options
  • Save epalm/4041856 to your computer and use it in GitHub Desktop.
Save epalm/4041856 to your computer and use it in GitHub Desktop.
inheritance=no, interfaces=yes
interface IGulpable
{
void Gulp();
}
class CokeBottle : IGulpable
{
public decimal Volume { get; set; }
public CokeBottle()
{
Volume = 355; // mL
}
public void Gulp()
{
Volume = Volume - 40;
}
}
class WaterBottle : IGulpable
{
public decimal Volume { get; set; }
public WaterBottle()
{
Volume = 750; // mL
}
public void Gulp()
{
Volume = Volume - 40;
}
}
class Person
{
public void Drink(IGulpable beverage)
{
beverage.Gulp();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment