• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Recursion and String Manipulation

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 17734
302
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic