low coupling/ high cohesion?

I am studying OOD concepts, and am wondering if this code presents loose coupling/ high cohesion. If it doesn't, then how could I fix it?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
class Product{
public:
        Product( int quantity, float price ) : p_quantity(quantity), p_price(price){}

	float getTotalPrice(){
		return p_quantity * p_price;
	}

private:
	int p_quantity;
	float p_price;
};

class Inventory{
public:
	Inventory(){
		productSum = 0;
	}

        void addItem( Product product ){
                items.push_back(product);
        }

	float getSum(){
		for( auto productIndex = items.begin();
		productIndex != items.end(); productIndex++ ){
			productSum += productIndex->getTotalPrice();
		}
		 return productSum;
	}
private:
	float productSum;
	std::vector<Product> items;
};
Topic archived. No new replies allowed.