@author Yvonne Wang @author Joel Costigliola
| 19 | * @author Joel Costigliola |
| 20 | */ |
| 21 | public class Employee { |
| 22 | |
| 23 | // intentionally public to test retrieval of a public field that is not a property |
| 24 | public long id; |
| 25 | // name is both a public field and a property => will be accessed as a property by extracting code |
| 26 | public Name name; |
| 27 | // surname is only a public field |
| 28 | public Name surname; |
| 29 | // keep private to test we are able to read property that is not a public field |
| 30 | private int age; |
| 31 | |
| 32 | public Employee() {} |
| 33 | |
| 34 | public Employee(long id, Name name, int age) { |
| 35 | this.id = id; |
| 36 | setName(name); |
| 37 | setAge(age); |
| 38 | } |
| 39 | |
| 40 | public Name getName() { |
| 41 | return name; |
| 42 | } |
| 43 | |
| 44 | public void setName(Name name) { |
| 45 | this.name = name; |
| 46 | } |
| 47 | |
| 48 | public int getAge() { |
| 49 | return age; |
| 50 | } |
| 51 | |
| 52 | public void setAge(int age) { |
| 53 | this.age = age; |
| 54 | } |
| 55 | |
| 56 | // pure property not backed by a field |
| 57 | public boolean isAdult() { |
| 58 | return age > 18; |
| 59 | } |
| 60 | |
| 61 | @Override |
| 62 | public String toString() { |
| 63 | return format("%s[id=%d, name=%s, age=%d]", getClass().getSimpleName(), id, name, age); |
| 64 | } |
| 65 | } |
nothing calls this directly
no outgoing calls
no test coverage detected