It is my job to store the workout routine for a given individual in a `multimap<string, Exercise*>` using an overloaded extraction operator in main. I wanted to know if my code for said operator can be simplified and made more intuitive. There are three classes, but I have only shown `Routines`; the others seem trivial to include. Implementations will be done in the header file. I will be extracting information from the following file (routine.txt):

```
Donald Duck,2
Chin-ups,30
Lat Pulldown,20,90
David Ash, 2
Push-ups,5
Wrist curl,10, 2

```

The format is `name,numberOfExercises` followed by numberOfExcercises exercises. Each exercise involves weights or does not. A weighted exercise is formatted as `exerName,reps,weight`. A non-weighted exercise is formatted as `exerName,reps`. The inclusion of a space after a comma is not a mistake. main contains the following:

```
int main() {
   Routines routines;
   string name;
   ifstream inf("routines.csv");

   inf >> routines;
}

```

The routines class has the following:

```
#include <fstream>
#include <map>
#include "exercise.h"
#include "weightedexercise.h"

using namespace std;

class Routines
{
  multimap<string, Exercise*> routineMap;

public:
  friend istream& operator>>(istream& is, Routines& rout)
  {
    string name, line;
    char comma;
    int numEx, rep, weight = 0;
    // numEx is number of exercises.
    // name is name of person. line is the exercise information.

    getline(is, name, ',');

    do
    {
      is >> numEx;
      getline(is, line);

      for(int i = 0; i < numEx; i++)
      {
        getline(is, line, ',');
        is >> rep;
        is.get(comma);
        if(comma == ',')
          is >> weight;

        if(weight)
        {
          rout.routineMap.insert(multimap<string,
          Exercise *>::value_type(name, new WeightedExercise(line, rep, weight)));
          getline(is, line);
        }
        else
        {
          rout.routineMap.insert(multimap<string,
          Exercise *>::value_type(name, new Exercise(line, rep)));
        }

        weight = 0;
      }
    } while(getline(is, name, ','));
  }
};

```