Created
November 21, 2018 10:44
-
-
Save JarkoDubbeldam/8106ce1043a7cb4bd0b1deb3446e4fd7 to your computer and use it in GitHub Desktop.
How much did Eater eat
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
public interface IEatable { | |
bool Eat(); | |
} | |
public class Wateringhole : IEatable { | |
public bool Eat() { | |
// Always eat 1, so don't need to return anything. | |
// Whatever | |
return true; | |
} | |
} | |
public class SomeOtherSource : IEatable { | |
public bool Eat() { | |
// Always eat 2. How do I communicate that? | |
return true; | |
} | |
} | |
public class Eater { | |
public void Eat(IEatable food) { | |
food.Eat(); | |
// Howmuch did I eat now? | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Het punt hier is dat Eater niet weet (en niet hoeft te weten) wat hij precies aan het eten is. Zolang hij maar weet hoeveel voedsel dat opgeleverd heeft.