Last active
June 6, 2018 11:22
-
-
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.
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
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