Skip to content

Instantly share code, notes, and snippets.

@JarkoDubbeldam
Created November 21, 2018 10:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JarkoDubbeldam/8106ce1043a7cb4bd0b1deb3446e4fd7 to your computer and use it in GitHub Desktop.
Save JarkoDubbeldam/8106ce1043a7cb4bd0b1deb3446e4fd7 to your computer and use it in GitHub Desktop.
How much did Eater eat
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?
}
}
@JarkoDubbeldam
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment