| Author |
Class help with character replacing?
|
M. Mills
Greenhorn
Joined: Jan 22, 2009
Posts: 2
|
|
Hi!
I have an assignment where I take input and search for and replace certain letters with others to create a code, and then I decode it. I'm confused about how to create create a loop to search for the letters. I know I use a if else statement inside the looping statement, but I don't know how to form it.
This is the file with the classes:
And here is the file that uses the classes:
Thank you so much!
[edit]Add code tags and change comments to /* */ type so as to fit width of screen. CR[/edit]
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16686
|
|
It has to be something like ag',r replaces v, but I always get "Unclosed character literal."
Something like what??? Not sure what you are trying to write here.
String encryptdSntnc = myCryptObj.encrypt(sntnc); This is the spot where I'm told that "encrypt() in Crypto cannot be applied to ( java.lang.String)."
Your encrypt() method doesn't take parameters -- it is called with a single string parameter here.
String decryptdSntnc = myCryptObj.decrypt(encryptdSntnc); This is the other spot.
Your decrypt() method doesn't take parameters -- it is called with a single string parameter here.
Henry
|
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
|
 |
M. Mills
Greenhorn
Joined: Jan 22, 2009
Posts: 2
|
|
|
What exactly do you mean by a single string parameter?
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16686
|
|
M. Mills wrote:What exactly do you mean by a single string parameter?
Your code.... calls the encrypt method... right here...
String sntnc = kbReader.nextLine();
System.out.println("Original sentence = " + sntnc);
Crypto myCryptObj = new Crypto();
String encryptdSntnc = myCryptObj.encrypt(sntnc);
Notice that you pass it a single parameter? Named sntnc? And notice that it is a string? .... aka a single string parameter?
Henry
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32644
|
|
Welcome to JavaRanch
Please use code tags (read this FAQ) and break long comments into separate lines. I have edited your post, and you can see how much better it looks.
|
 |
 |
|
|
subject: Class help with character replacing?
|
|
|