On Sep 4, 9:15 pm, "Estes, Tammy" <[EMAIL PROTECTED]> wrote:
> Just when I think I have it...
>
> Now I am TOTALLY confused!! There has to be a simpler way of explaining
> this...
Apart from writing the program for you I don't see...
That's simple. Focus just on what is requested.
You are requested to write a method which constructs a name based on
other names. Point. That's all, nothing else.
To do that, you should:
1 - Have the names:
String name = ["foo", "bar", "..."]
No matter how you get them, once you get them, they are in the form
above.
2 - Have ay string to receive the result of your method once it
returns the result.
String newName;
That's enough to begin with. You will initialize it in the next step.
3 - Call the method with the array name as parameter and receive the
result in your new String
newName = yourmethodhere(name);
4 - Print the newName
I'll guess you don't need explanation here.
Here we go on constructing the new name
1 - The method should be static
2 - It uses the array name as parameter
3 - It returns the new name, hence a String
That results in a method:
public static String yourmethodnamehere(String[] name) {
...
}
What to put in it?
1 - You need a temporary string to construct step by step the new name
as you loop through the array of names passed as parameter.
This temporary String is empty at the beginning.
String newName = "";
2 - Next, you loop through the array of names, extract the second
character of each name, and add it to your temporary string.
What happens:
you read the first name, say "Toto", you extract the o, you put in
newName what was in it before, plus the o.
In java parlance, that gives:
newName = newName + ...
Again the ... is for you to guess. It is based on the current name in
the array your are inspecting. On that name it calls a method that
extract the character at a given index. More than that, I would not
say, up to you to read the javadoc on String.
So, the first time, it gives "o", as there was nothing in newName; the
second time, it gives "or", provided that the second name in the array
was something like Armand, and so on.
Now, I think you can send your homework, it is done.
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---