Java 7, 390 339 335 bayt
String c(String s){String h="Hillary Clinton",d="Donald Trump",r=h+" ===Q===>\n"+d+" ===X===>\nZ===J===>";boolean H=h.equals(s),D=d.equals(s);for(int i=s.length();i++<18;s+=" ");return r.replace(H?"Q":D?"X":"J","-----").replace(H|D?"Z":"~","____________ ").replaceAll(H?"X|J":D?"Q|J":"Q|X"," ").replace(H|D?"~":"Z",s);}
Test edilmemiş ve test kodu:
Burada deneyin.
class M{
static String c(String s){
String h = "Hillary Clinton",
d = "Donald Trump",
r = h+" ===Q===>\n"+d+" ===X===>\nZ===J===>";
boolean H = h.equals(s),
D = d.equals(s);
for(int i = s.length(); i++ < 18; s += " ");
return r.replace(H?"Q":D?"X":"J", "-----")
.replace(H|D?"Z":"~", "____________ ")
.replaceAll(H?"X|J":D?"Q|J":"Q|X", " ")
.replace(H|D?"~":"Z", s);
}
public static void main(String[] a){
System.out.println(c("Hillary Clinton"));
System.out.println();
System.out.println(c("Donald Trump"));
System.out.println();
System.out.println(c("Anyone else?.."));
System.out.println();
System.out.println(c("S"));
System.out.println();
System.out.println(c("Anyone who is willing to take the job"));
}
}
Çıktı:
Hillary Clinton ===-----===>
Donald Trump === ===>
____________ === ===>
Hillary Clinton === ===>
Donald Trump ===-----===>
____________ === ===>
Hillary Clinton === ===>
Donald Trump === ===>
Anyone else?.. ===-----===>
Hillary Clinton === ===>
Donald Trump === ===>
S ===-----===>
Hillary Clinton === ===>
Donald Trump === ===>
Anyone who is willing to take the job===-----===>