• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

need help with Decode method

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys!, im new to the forum. I need a little help with encoding and decoding words. Here are my two methods for encoding and decoding. As of now the output is working for the encoding, but the decoding isnt.


 
Manu Carruso
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
note: Constants.DECODE_SHIFT value is 23.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So the "decode" part is not supposed to do the reverse of the "encode" part? In that case you need to tell us what the "decode" part is supposed to do, and how exactly it is not working.
 
Bartender
Posts: 1166
17
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The two methods are not inverses of one another ! What made you think the decode() method was the inverse of the encode() . The inverse of your encode() method is itself . The decode() method is a caesar cipher and the inverse of it is very very similar to itself.
 
Manu Carruso
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the encode() method is supposed to reverse characters in a string, while the decode() method is supposed to turn the characters back into the original word.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you say "turn... back into the original word", does that mean the word before you reversed its characters? If so then, no, it doesn't do that. And Richard already pointed out that the way to undo the "reverse the order of characters in the word" operation is simply to do it again. The code in your posted decode() method is irrelevant to that.

Or does it mean something else?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic