Last active
April 21, 2020 20:04
-
-
Save tacoberu/fdb8769de81ec7a5dd042b2bec6444ed to your computer and use it in GitHub Desktop.
Zapouzdření objektu.
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 Person | |
{ | |
private String name; | |
private Address address; | |
private int age; | |
public Person(String name, Address address, int age) | |
{ | |
this.assertName(name); | |
this.assertAddress(address, age); | |
this.assertAge(age); | |
this.name = name; | |
this.address = address; | |
this.age = age; | |
} | |
public void setName(String val) { | |
this.assertName(val); | |
this.name = val; | |
} | |
public void setAddress(Address val) { | |
this.assertAddress(val, this.age); //Člověk mladší devatenácti nemůže měnit adresu | |
this.address = val; | |
} | |
public void setAge(int val) { | |
this.assertAge(val); | |
this.age = val; | |
} | |
// další metody | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment