Results 1 to 2 of 2
- 07-09-2012, 08:02 PM #1
Member
- Join Date
- Jul 2012
- Posts
- 1
- Rep Power
- 0
trying to get modules to work together.. need help :)
I keep getting an error: "ThreadGroup.uncaughtException(thread,Throwabl e) line: not available"
I don't know what this means. I'm guessing I'm not linking my modules correctly can some one interpret?
Java Code:import java.util.*; @SuppressWarnings("unused") public class Decoder { public static void main(String[] args) { decrypt(); keywork(null, null); } static void decrypt() { String codedline = "ilyh wkrxvdqg, wzr kxqguhg dqg qlqhwb-wkuhh"; char[] cwarr = codedline.toCharArray(); String dcline = ""; for(char x : cwarr) { if(Character.isLetter(x)) { int c = (int)x; c = c - 3; if(c > 90 && c < 97) { c = c + 26; } x = (char)c; dcline = dcline + x; }else { dcline = dcline + x; } } System.out.println(dcline); } static void keywork(String dcline, HashMap<String, Integer> hm) { int x; for(int i = 1, sw = 0; i == dcline.length(); i++) { String strchk = dcline.substring(sw, i); int n = hm.get(strchk); }; } private static HashMap<String, Integer> keywork() { HashMap<String, Integer> hm = new HashMap<String, Integer>(29); hm.put("ONE", 1); hm.put("TWO", 2); hm.put("THREE", 3); hm.put("FOUR", 4); hm.put("FIVE", 5); hm.put("SIX", 6); hm.put("SEVEN", 7); hm.put("EIGHT", 8); hm.put("NINE", 9); hm.put("TEN", 10); hm.put("ELEVEN", 11); hm.put("TWELVE", 12); hm.put("THIRTEEN", 13); hm.put("FOURTEEN", 14); hm.put("FIFTEEN", 15); hm.put("SIXTEEN", 16); hm.put("SEVENTEEN", 17); hm.put("EIGHTEEN", 18); hm.put("NINETEEN", 19); hm.put("TWENTY", 20); hm.put("THIRTY", 30); hm.put("FOURTY", 40); hm.put("FIFTY", 50); hm.put("SIXTY", 60); hm.put("SEVENTY", 70); hm.put("EIGHTY", 80); hm.put("NINETY", 90); hm.put("HUNDRED", 100); hm.put("THOUSAND", 1000); return hm; } }Last edited by BtRaE; 07-09-2012 at 08:05 PM.
- 07-10-2012, 06:03 PM #2
Member
- Join Date
- Apr 2012
- Posts
- 12
- Rep Power
- 0
Re: trying to get modules to work together.. need help :)
First, get rid of the suppress warning so you can see what's going on.
Second, decrypt works but since dcline is a local variable it's not available anywhere else.
Third, you are passing null, null to keywork. Since it's looking for the string dcline (which isn't available) and a HashMap named hm (which hasn't been created) no good can come from this.
It looks like you are trying to pass it a string like "two hundred and fifty three" and print out 253. You need to return dcline from decrypt to main in order to pass it to keywork. You also can change
private static HashMap<String, Integer> keywork()
to
private static HashMap<String, Integer> createMap()
and call it before you call keywork to initialize the hashmap. The resulting main would look like this:
String dcline = decrypt();
HashMap<String, Integer> hm = createMap();
keywork(dcline, hm);
Now as to keywork itself, not knowing exactly what you are trying to do, this will need to be reworked. Assuming that you are trying to convert string numbers to numbers it doesn't make since to look at things in a char[]. You also have to get rid of extraneous things like "hundred and". The following will do the conversion in the keywork method:
String strchk = "THREE";
int n = hm.get(strchk);
System.out.println(n);
You need to figure out how to parse dcline and what to do with the results of the lookup.
Similar Threads
-
standard communication protocol among modules
By a1prashant in forum Advanced JavaReplies: 7Last Post: 01-09-2011, 01:39 PM -
modules in notepad
By joypik in forum New To JavaReplies: 6Last Post: 11-22-2010, 05:47 PM -
how many modules?
By joypik in forum New To JavaReplies: 13Last Post: 08-04-2010, 04:46 AM -
Inventory book store -Modules
By saran87 in forum New To JavaReplies: 2Last Post: 08-24-2009, 02:14 PM -
Creating J2ee Modules In NetBeans IDE
By JavaForums in forum NetBeansReplies: 0Last Post: 07-30-2007, 11:13 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks