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
40
41
42
43
44
45





















46
47
48
49
50
51
52
..
79
80
81
82
83
84
85
86
87
88
89
90
91

    AddTrader( eCommodity::wood, eCommodity::sand, 2 );
    AddTrader( eCommodity::sand, eCommodity::gras, 0.5 );
    AddTrader( eCommodity::gras, eCommodity::sand, 1);
    AddTrader( eCommodity::sand, eCommodity::wood, 0.25);
    AddTrader( eCommodity::gras, eCommodity::wood, 0.5);
}






















void cVillage::Display()
{
    int index = 0;
    graph_traits<trade_graph_t>::vertex_iterator vi, vi_end;
    for (boost::tie(vi, vi_end) = vertices(myGraph); vi != vi_end; ++vi)
    {
................................................................................
            index++;
        }
    }
}
int main()
{
    cVillage village;
    village.ConstructProblem1();
    village.Display();
    village.Travel();

    return 0;
}







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|





39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
...
100
101
102
103
104
105
106
107
108
109
110
111
112

    AddTrader( eCommodity::wood, eCommodity::sand, 2 );
    AddTrader( eCommodity::sand, eCommodity::gras, 0.5 );
    AddTrader( eCommodity::gras, eCommodity::sand, 1);
    AddTrader( eCommodity::sand, eCommodity::wood, 0.25);
    AddTrader( eCommodity::gras, eCommodity::wood, 0.5);
}

void cVillage::ConstructProblem2()
{
    static eCommodity hold = eCommodity::wood;
    static float quantity = 1;
    myTraveler.myHold = &hold;
    myTraveler.myQuantity = &quantity;
    myTraveler.myInitiallHold = hold;
    myTraveler.myInitialQuantity = quantity;

    static vector<int> path;
    myTraveler.myPath = &path;

    AddTrader( eCommodity::wood,  eCommodity::wood, 1);

    AddTrader( eCommodity::wood, eCommodity::sand, 2 );
    AddTrader( eCommodity::sand, eCommodity::gras, 0.5 );
    AddTrader( eCommodity::gras, eCommodity::sand, 1);
    AddTrader( eCommodity::sand, eCommodity::wood, 0.25);
    AddTrader( eCommodity::gras, eCommodity::wood, 0.3333);
}

void cVillage::Display()
{
    int index = 0;
    graph_traits<trade_graph_t>::vertex_iterator vi, vi_end;
    for (boost::tie(vi, vi_end) = vertices(myGraph); vi != vi_end; ++vi)
    {
................................................................................
            index++;
        }
    }
}
int main()
{
    cVillage village;
    village.ConstructProblem2();
    village.Display();
    village.Travel();

    return 0;
}

Changes to trade.h.

170
171
172
173
174
175
176

177
178
179
180
181
182
183

    void AddTrader(
                   eCommodity sell,
                   eCommodity buy,
                   float price );

    void ConstructProblem1();


    void Display();

    void ConstructSensibleTrips();

     void Travel()
    {







>







170
171
172
173
174
175
176
177
178
179
180
181
182
183
184

    void AddTrader(
                   eCommodity sell,
                   eCommodity buy,
                   float price );

    void ConstructProblem1();
    void ConstructProblem2();

    void Display();

    void ConstructSensibleTrips();

     void Travel()
    {