Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
21
Task/Comma-quibbling/Java/comma-quibbling.java
Normal file
21
Task/Comma-quibbling/Java/comma-quibbling.java
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
public class Quibbler {
|
||||
|
||||
public static String quibble(String[] words) {
|
||||
String qText = "{";
|
||||
for(int wIndex = 0; wIndex < words.length; wIndex++) {
|
||||
qText += words[wIndex] + (wIndex == words.length-1 ? "" :
|
||||
wIndex == words.length-2 ? " and " :
|
||||
", ";
|
||||
}
|
||||
qText += "}";
|
||||
return qText;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(quibble(new String[]{}));
|
||||
System.out.println(quibble(new String[]{"ABC"}));
|
||||
System.out.println(quibble(new String[]{"ABC", "DEF"}));
|
||||
System.out.println(quibble(new String[]{"ABC", "DEF", "G"}));
|
||||
System.out.println(quibble(new String[]{"ABC", "DEF", "G", "H"}));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue