Skip to content

Instantly share code, notes, and snippets.

@renaudbedard
Created September 5, 2014 21:25
Show Gist options
  • Save renaudbedard/fb3385384468fdd19d3e to your computer and use it in GitHub Desktop.
Save renaudbedard/fb3385384468fdd19d3e to your computer and use it in GitHub Desktop.
public interface IEdible
{
void Eat();
}
public interface IOrganic
{
void ApplyDubiousHealthBenefits(Body a);
}
public class PriceyApple : IEdible, IOrganic
{
public void Eat()
{
// chomp
}
public void ApplyDubiousHealthBenefits(Body a)
{
// a.omega3 += 5
}
}
public static class Market
{
List<IEdible> sales = new List<IEdible>();
float moneyMade;
public static void Buy(IEdible a)
{
sales.Add(a);
if (a instanceof IOrganic)
moneyMade += 10;
else
moneyMade += 5;
}
}
public static class Program
{
public static void Main()
{
PriceyApple apple = new PriceyApple();
Market.Buy(a);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment