|
| 1 | +# Instructions |
| 2 | + |
| 3 | +In this exercise you'll be writing code to print name badges for factory employees. |
| 4 | + |
| 5 | +## 1. Print a badge for an employee |
| 6 | + |
| 7 | +Employees have an ID, name and department name. Employee badge labels are formatted as follows: `"[id] - name - DEPARTMENT"`. |
| 8 | +Implement the `Badge.print()` method to return an employee's badge label: |
| 9 | + |
| 10 | +```java |
| 11 | +Badge badge = new Badge(); |
| 12 | +badge.print(734, "Ernest Johnny Payne", "Strategic Communication"); |
| 13 | +// => "[734] - Ernest Johnny Payne - STRATEGIC COMMUNICATION" |
| 14 | +``` |
| 15 | + |
| 16 | +Note that the department should be uppercased on the label. |
| 17 | + |
| 18 | +## 2. Print a badge for a new employee |
| 19 | + |
| 20 | +Due to a quirk in the computer system, new employees occasionally don't yet have an ID when they start working at the factory. |
| 21 | +As badges are required, they will receive a temporary badge without the ID prefix. Modify the `Badge.print()` method to support new employees that don't yet have an ID: |
| 22 | + |
| 23 | +```java |
| 24 | +Badge badge = new Badge(); |
| 25 | +Badge.print(null, "Jane Johnson", "Procurement"); |
| 26 | +// => "Jane Johnson - PROCUREMENT" |
| 27 | +``` |
| 28 | + |
| 29 | +## 3. Print a badge for the owner |
| 30 | + |
| 31 | +Even the factory's owner has to wear a badge at all times. |
| 32 | +However, an owner does not have a department. In this case, the label should print `"OWNER"` instead of the department name. |
| 33 | +Modify the `Badge.print()` method to print a label for the owner: |
| 34 | + |
| 35 | +```java |
| 36 | +Badge badge = new Badge(); |
| 37 | +badge.print(254, "Charlotte Hale", null); |
| 38 | +// => "[254] - Charlotte Hale - OWNER" |
| 39 | +``` |
| 40 | + |
| 41 | +Note that it is possible for the owner to also be a new employee: |
| 42 | + |
| 43 | +```java |
| 44 | +Badge badge = new Badge(); |
| 45 | +badge.print(null, "Charlotte Hale", null); |
| 46 | +// => "Charlotte Hale - OWNER" |
| 47 | +``` |
0 commit comments