reset password
Author Message
epascua
Posts: 47
Posted 23:46 Sep 26, 2016 |

Hello! I was reading over the lab again and there's a few things I wanna recheck on.

"Add a method that clears the list of monster attacks"

I wasn't exactly clear on what this was asking. Is this asking to clear the array list of monster attacks (so that it's empty)? If so, what's the point of doing this if it the list is reading off your .txt/.csv file?

Edit: Also, "Add an item to the main menu that calls this method". I named my method to save the attacks "saveAttack", does this mean I'll have to use my "saveAttack" in the menu? Just double checking, kind of confused with the term item.

Last edited by epascua at 23:47 Sep 26, 2016.
rcamach7
Posts: 31
Posted 08:53 Sep 27, 2016 |

Yes, this method first clears any data that's in the monster attacks, then reads the new data from the csv file that you created/generated. It's to clear any old data so it only shows the content from the csv file you're reading from.

Since all of this is done in one method just create a menu item (i.e. a choice) that runs this method, like menu choices you created in lab 3. Yeah if you create any methods that do something, you want to give the user the ability to choose it.

Last edited by rcamach7 at 08:53 Sep 27, 2016.
epascua
Posts: 47
Posted 09:33 Sep 27, 2016 |

Thanks! That makes so much sense now. I'm guessing for the second question as well, you'll need to add it onto the menu as well? 

Edit: Also, to clear the array list do we use the .clear() method? Or the .removeAll() method?

Actually, I haven't tried it yet but after readin through what the method does I'm guessing we don't use either of them because they only delete the elements but not actually remove any length of the array.. Do we need to iterate through the entire array and delete each individually at their given index?

Last edited by epascua at 09:53 Sep 27, 2016.
jhurley
Posts: 207
Posted 10:58 Sep 27, 2016 |

.clear()