(11-12-2012, 11:44 AM)AnyOldName3 Wrote: That's not ideal for me to do, as the text may have lowercase characters which I need to skip (It's to help me decrypt ceaser shift and affine shift text, and the convention is that plaintext is in lowercase. There may be a situation where I lose my frequency table having already solved several letters, so won't want frequencies of these letters, as this could get confusing.)
So you want to skip lowercases altogether? Just change the two conditional statements:
Code:
If Character is a letter (use isLetter()) AND Character already exists in the HashMap (use containsKey()) AND the character is Uppercase (use isUpper()) - Then
...
...
Else If Character is a letter AND Character does NOT already exist in Hashmap AND the character is Uppercase (use isUpper()) - Then
...
...Or do you mean you need to skip specific lower case characters? For that, just check that the characters aren't the ones you don't want. The conditional statement could get quite long, nothing wrong with that though (unless it's a ridiculous amount...)
Code:
If Character is a letter (use isLetter()) AND Character already exists in the HashMap (use containsKey()) AND the character is not blacklisted (e.g. != "a" or != "b")
...
...
Else If Character is a letter AND Character does NOT already exist in Hashmap AND the character is Uppercase (use isUpper()) AND the character is not blacklisted (e.g. != "a" or != "b") - Then
...
...You mentioned having trouble grabbing just one character from a string to do comparisons, right? Use the charAt() function:
Code:
String many_letterz = "words are words";
if(many_letterz.charAt(0) == "w") { System.out.println("Yeah, 1st character is w"); }
else { System.out.println("Nope, not w"); }
