import java.util.List;
import java.util.Map;
public class Recipient {
private static Map<String,String> STREETS = Map.of(
"M13 9PL", "Oxford Rd",
"M14 5TQ", "Wilmslow Rd"
);
private String name, postcode, address;
public Recipient(String name, String postcode) {
this.name = name;
this.postcode = postcode;
this.address = STREETS.get(postcode.toUpperCase());
}
public String prepareLetter() {
return name + "\n" + address.toUpperCase() + "\n" + postcode;
}
public static void main(String[] args) {
List<Recipient> recipients = List.of(
new Recipient("Alice", "M13 9PL"),
new Recipient("Bob", "M14 5UN")
);
// ..
for (Recipient r : recipients) {
System.out.println(r.prepareLetter());
}
}
}