• Post Reply Bookmark Topic Watch Topic
  • New Topic

Recursion and String Manipulation  RSS feed

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, I've got this project for an intermediate java class. I'm wondering if anyone can give me some insight as to how to manipulate strings recursively. We just went into recursion and right now the concept escapes me. Any pointers on how to tackle this problem would help me immensely.

[ EJFH: Fixed URL ]
[ November 28, 2005: Message edited by: Ernest Friedman-Hill ]
 
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greg, you wouldn't manipulate the string recursively so much as you would break it up and test it recursively. You can use the String.substring() method to break the string down. You will also need the String.indexOf() method to disect the word into different parts.

Here's a hint:

test for UWF word:
- extract parts for testing a UWF word.
- do parts pass test?

test for Florida word:
- extract parts for testing a Florida word.
- do parts pass test?

Recursion comes into play because UWF and Florida words are tested in terms of either themselves or each other. Translating the tests for each into Java shouldn't be that difficult based on the definitions given.

Edit: here's the JUnit test I used to solve it (my solution was ~ 100 lines of code, including comments):


[ November 28, 2005: Message edited by: Junilu Lacar ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!