Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:problem 2
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:9e6ffedda7a285cf4cba3240354488c270ac7485
User & Date: ravenspoint 2016-05-29 00:19:04
Context
2016-05-29
11:49
document the interfaces forthe trader classes check-in: 6f9b6eeb05 user: ravenspoint tags: trunk
00:19
problem 2 check-in: 9e6ffedda7 user: ravenspoint tags: trunk
00:12
cVillage::AddTrader method check-in: bba070fa45 user: ravenspoint tags: trunk
Changes

Changes to trade.cpp.

    39     39   
    40     40       AddTrader( eCommodity::wood, eCommodity::sand, 2 );
    41     41       AddTrader( eCommodity::sand, eCommodity::gras, 0.5 );
    42     42       AddTrader( eCommodity::gras, eCommodity::sand, 1);
    43     43       AddTrader( eCommodity::sand, eCommodity::wood, 0.25);
    44     44       AddTrader( eCommodity::gras, eCommodity::wood, 0.5);
    45     45   }
           46  +
           47  +void cVillage::ConstructProblem2()
           48  +{
           49  +    static eCommodity hold = eCommodity::wood;
           50  +    static float quantity = 1;
           51  +    myTraveler.myHold = &hold;
           52  +    myTraveler.myQuantity = &quantity;
           53  +    myTraveler.myInitiallHold = hold;
           54  +    myTraveler.myInitialQuantity = quantity;
           55  +
           56  +    static vector<int> path;
           57  +    myTraveler.myPath = &path;
           58  +
           59  +    AddTrader( eCommodity::wood,  eCommodity::wood, 1);
           60  +
           61  +    AddTrader( eCommodity::wood, eCommodity::sand, 2 );
           62  +    AddTrader( eCommodity::sand, eCommodity::gras, 0.5 );
           63  +    AddTrader( eCommodity::gras, eCommodity::sand, 1);
           64  +    AddTrader( eCommodity::sand, eCommodity::wood, 0.25);
           65  +    AddTrader( eCommodity::gras, eCommodity::wood, 0.3333);
           66  +}
    46     67   
    47     68   void cVillage::Display()
    48     69   {
    49     70       int index = 0;
    50     71       graph_traits<trade_graph_t>::vertex_iterator vi, vi_end;
    51     72       for (boost::tie(vi, vi_end) = vertices(myGraph); vi != vi_end; ++vi)
    52     73       {
................................................................................
    79    100               index++;
    80    101           }
    81    102       }
    82    103   }
    83    104   int main()
    84    105   {
    85    106       cVillage village;
    86         -    village.ConstructProblem1();
          107  +    village.ConstructProblem2();
    87    108       village.Display();
    88    109       village.Travel();
    89    110   
    90    111       return 0;
    91    112   }

Changes to trade.h.

   170    170   
   171    171       void AddTrader(
   172    172                      eCommodity sell,
   173    173                      eCommodity buy,
   174    174                      float price );
   175    175   
   176    176       void ConstructProblem1();
          177  +    void ConstructProblem2();
   177    178   
   178    179       void Display();
   179    180   
   180    181       void ConstructSensibleTrips();
   181    182   
   182    183        void Travel()
   183    184       {