Constructors with conditionals

Hello guys, I'm learning C++ step by step.

github:
https://github.com/CreativeSoftware/DiamondQt

This is my classDiagram:
https://dl.dropboxusercontent.com/u/710615/class%20diagramV3.png


I want the book price object (Bprice) has its value accordding to the marker object. When the marker is equal to "blue" on price, green another.
I think this is possible, I don't know how !

I thought this code be solved with this
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
void Book::setBPrice(int Bprice)
{
    //bPrice_= bPrice;
    if (isMarkerBlue(marker_))
        Bprice_ = 10;
    else
        Bprice_= 5;
}

bool Book::isMarkerBlue(string const &marker)
{
    string str1 = "blue";

     if (str1.compare(marker) == 0)
         cout << "the marker is blue" << "\n";
         return true;

}


But it is far of being a solution
Last edited on
Topic archived. No new replies allowed.