So I have a String/txt file:
All purchases: blabla : 1 derp : 20 blabla : 1 herp : 30
This is just an example, a real file will be generated based on the users input
So what I need to do is combine the similar strings with similar names (First part) together and make them look like this: (name) : (number) x(amount of same strings)
For example lets take the file that we had:
All purchases: blabla : 1 derp : 20 blabla : 1 herp : 30
After parsing it must look like: All purchases: blabla : 1 x2 derp : 20 herp : 30
I have tried writing down the last value into a variable and checking it with the next value, but what if the values are in a different order? That’s where I got stuck.
Since each entry has three components:
[name] : [number]
You can do a few things here. Something along the lines of:
You’ll of course have to remove the leading ‘All purchases:’, but now everything is in the arraylist in the form [name] : [number]
You simply have to determine how many of each there are. From here you can sort them and then count them.