Campbell Ritchie wrote:The original poster was told to use a List. I think a List is easier for run-length recording than a Map.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
I can create a list and read a test file one line at a time and save each line as an entry in the list.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Hemmmm, hemmmm!Yesterday, I wrote: . . . Hint: Make a class which has two fields, one for "fruit" and the other for "count". . .
Campbell Ritchie wrote:
It might be easier to use a Map, but that will give a simple count, not run-length counting. You will need to use a List, as it says in the instructions you were given.
"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- Antoine de Saint-Exupery
Thomas Dallaire wrote:@Nick,
Yup, guess you're in the same situation eh haha
@Fred,
That's the part I can't figure out how to do...i'm not sure how to create a list class that takes both elements and the only other way I can see to do it is to append the number to the entry on the string. Im guessing that's not what you're thinking of though?
And I appreciate the help eh! Sorry if I seem slow on this
If you miss hints like that, you deserve all you getI wrote: . . . Hint: Make a class which has two fields, one for "fruit" and the other for "count". . .
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |