reset password
Author Message
velder0
Posts: 16
Posted 19:12 Sep 06, 2016 |

im having a hard time passing the first method to main. 

When he says pass a reference to main should it look like an array reference? 

Because when I print the list I have for the return it prints the names imputed into the list. 

When the user goes through my menu selection I can go through the easy problem but where it's supposed to say the name it puts []. So it'll be like day 0 [] does the dishes

Am I making sense? Ahah

can anyone help thank you! 

epascua
Posts: 47
Posted 20:14 Sep 06, 2016 |

You're talking about the "easy" and "hard" problem (whichever you decide to do first), right?

I think he calls it a reference just to be really specific the datatype (how it's different from a primitive datatype), but what you need to be sure of is to not change the original array.

For your question, do you mean it literally prints the brackets? I haven't tried it yet, but if so, I think you're not printing the actual element inside the index of each and instead you're printing the address. I had a problem similar but instead of the brackets it would totally skip the first index (in this case 0). I found the solution had to do with the scanner.nextLine();, however I'm not sure if that's your question. 

My best advice is to think of the list similar to arrays (they aren't the same but similar), when printing the elements, you would need to use the index then used the methods found on slide 5 lecture 3 to print the specific values of your array list.

Hope this helps! c:

Last edited by epascua at 20:16 Sep 06, 2016.
velder0
Posts: 16
Posted 20:34 Sep 06, 2016 |

Yes thank you! 

I think I figured out what I'm doing wrong. 

i don't think I'm putting in the right parameters.

if the first method is where the array list is created do I use the array list I created as the parameter for the easy hard problems, or do I call the method? I think that's why my inputs aren't tranferring. 

I think the brackets are telling me that the list is empty. 

I guess my last question would be is my friend method a list <string> method? Or an array[]? 

epascua
Posts: 47
Posted 20:44 Sep 06, 2016 |
velder0 wrote:

Yes thank you! 

I think I figured out what I'm doing wrong. 

i don't think I'm putting in the right parameters.

if the first method is where the array list is created do I use the array list I created as the parameter for the easy hard problems, or do I call the method? I think that's why my inputs aren't tranferring. 

I think the brackets are telling me that the list is empty. 

I guess my last question would be is my friend method a list <string> method? Or an array[]? 

It would be the list <string> for the method that makes the list, and also "list <string> name" for when you use it as input for any of the parameters for the hard/easy methods. 

velder0
Posts: 16
Posted 20:56 Sep 06, 2016 |

Thank you!!!!

and very last question! Haha

if my first method is list<string> listChild()

and my array list list<string> dishList which I return at the end of listChild

would I use listChild or dishList?

because the names pass through listChild but not my actual dishList return.

sorry is that's confusing haha

epascua
Posts: 47
Posted 21:17 Sep 06, 2016 |
velder0 wrote:

Thank you!!!!

and very last question! Haha

if my first method is list<string> listChild()

and my array list list<string> dishList which I return at the end of listChild

would I use listChild or dishList?

because the names pass through listChild but not my actual dishList return.

sorry is that's confusing haha

No problem! 

The way I solved it, I only used one list. That one list is for the names. What is the exact purpose of the dishList? I don't think it's necessary (however, if you find it easier then by all means use it).

However, the way I did it is by using one list. That list will ask for the number of children, then create an array list with the names (user inputted names) depending on how many children are there. That method then returns the list, and you will use that method in the two other methods: hard/easy problem.