View difference between Paste ID: kg1A29Db and aVMusG20
SHOW: | | - or go back to the newest paste.
1
public class Diamond {
2
3
    static final String BASE = "ZYXWVUTSRQPONMLKJIHGFEDCBABCDEFGHIJKLMNOPQRSTUVWXYZ";
4
5-
    public String generateDiamond(char current, char stop) {
5+
    public String generateDiamond(char c, char stop) {
6
        String unmaskedLine = BASE.substring(BASE.indexOf(stop), BASE.lastIndexOf(stop) + 1);
7-
        String maskedLine = unmaskedLine.replaceAll("[^" + current + "]", " ") + "\n";
7+
        String maskedLine = unmaskedLine.replaceAll("[^" + c + "]", " ") + "\n";
8
9-
        return (current == stop) ? maskedLine : maskedLine + generateDiamond(++current, stop) + maskedLine;
9+
        return (c == stop) ? maskedLine : maskedLine + generateDiamond(++c, stop) + maskedLine;
10
    }
11
12
    public static void main(String[] args) {
13
        Diamond diamond = new Diamond();
14
        System.out.println(diamond.generateDiamond('A', 'R'));
15
    }
16
}