Created
November 8, 2012 21:37
-
-
Save epalm/4041846 to your computer and use it in GitHub Desktop.
inheritance=yes, interfaces=yes
This file contains 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
interface IGulpable | |
{ | |
void Gulp(); | |
} | |
abstract class Bottle : IGulpable | |
{ | |
public decimal Volume { get; set; } | |
public void Gulp() | |
{ | |
Volume = Volume - 40; | |
} | |
} | |
class CokeBottle : Bottle | |
{ | |
public CokeBottle() | |
{ | |
Volume = 355; // mL | |
} | |
} | |
class WaterBottle : Bottle | |
{ | |
public WaterBottle() | |
{ | |
Volume = 750; // mL | |
} | |
} | |
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