Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Working with 2-dimensional arrays  RSS feed

 
Anthony Santiago
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So I need help with this. I'm working with two-dimensional arrays and so what I'm trying to do is to navigate through the 2-d arrays in a row (starting at the top left of the array like you are reading a paragraph).
I trying to write a method that returns the array with the following rules:

1) If the word begins with a vowel (a, e, i, o, u) : swap the word with the previous word on the same row
2) If the word is the first word on the row, then swap it with the word just above it; however, if the word is on the first row, then no swapping should occur.
3) If the word begins with a consonant, then swap the first and last characters of the word.

Ex. 2-dim array:
rice , egg, room
apple, java, owl

Converted:
apple, eicr, moor
egg, owl, avaj


This is what I have so far:
*I've got the tester class all set up and ready but I having trouble setting up the methods in the class below. This is essential what I need guidance for.*


Tester class:


If anyone could help me further with this it would be much obliged!
 
Anthony Santiago
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nevermind! Figured it out!
 
Campbell Ritchie
Marshal
Posts: 55698
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anthony Santiago wrote:. . . I'm working with two-dimensional arrays . . .
No, you aren't. There is no such thing as a 2D array in Java®, though there might be in other languages. What you have is an array of arrays which is better than a 2D array.

You have given yourself a very complicated exercise. You should start learning arrays with something simple, and consider changing words later.

And welcome to the Ranch
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!