Skip to content

Instantly share code, notes, and snippets.

@tacoberu
Last active June 6, 2018 11:22
Show Gist options
  • Save tacoberu/fccb88b255b72888d41e17528ae8df82 to your computer and use it in GitHub Desktop.
Save tacoberu/fccb88b255b72888d41e17528ae8df82 to your computer and use it in GitHub Desktop.
Příklad: Budu mět nějakou funkci/metodu, která bude validovat, zda dotyčný smí alkohol. Takže prohlásíme, že příchozí objekt musí být schopen se prokázat věkem.
class Age
{
private int val;
Age(int val)
{
assertInt(0, 150);
this.val;
}
int getVal()
{
return this.val;
}
}
interface Ageable
{
Age getAge();
}
interface HumanAgeable extends Ageable
{
}
class Foo
{
static assertAlcohol(HumanAgeable entry)
{
if (entry.getAge().getVal() < 18) {
throw new AssertException();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment