From 866a71ffd576fd10c4e309195016d86f0c8ed635 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 3 Sep 2012 21:58:08 +0300 Subject: Add const to more classes. --- src/shopitem.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/shopitem.cpp') diff --git a/src/shopitem.cpp b/src/shopitem.cpp index a9068bacb..8d91c6ca0 100644 --- a/src/shopitem.cpp +++ b/src/shopitem.cpp @@ -29,8 +29,9 @@ #include "debug.h" -ShopItem::ShopItem(int inventoryIndex, int id, unsigned char color, - int quantity, int price) : +ShopItem::ShopItem(const int inventoryIndex, const int id, + const unsigned char color, + const int quantity, const int price) : Item(id, 0, 0, color), mPrice(price), mShowQuantity(true) @@ -52,7 +53,7 @@ ShopItem::ShopItem(int inventoryIndex, int id, unsigned char color, addDuplicate(inventoryIndex, quantity); } -ShopItem::ShopItem (int id, unsigned char color, int price) : +ShopItem::ShopItem (const int id, const unsigned char color, const int price) : Item (id, 0, 0, color), mPrice(price), mShowQuantity(false) @@ -100,9 +101,9 @@ void ShopItem::update() } } -void ShopItem::addDuplicate(int inventoryIndex, int quantity) +void ShopItem::addDuplicate(const int inventoryIndex, const int quantity) { - DuplicateItem* di = new DuplicateItem; + DuplicateItem *const di = new DuplicateItem; di->inventoryIndex = inventoryIndex; di->quantity = quantity; mDuplicates.push(di); @@ -111,19 +112,20 @@ void ShopItem::addDuplicate(int inventoryIndex, int quantity) void ShopItem::addDuplicate() { - DuplicateItem* di = new DuplicateItem; + DuplicateItem *const di = new DuplicateItem; di->inventoryIndex = -1; di->quantity = 0; mDuplicates.push(di); } -int ShopItem::sellCurrentDuplicate(int quantity) +int ShopItem::sellCurrentDuplicate(const int quantity) { DuplicateItem* dupl = mDuplicates.top(); if (!dupl) return 0; - int sellCount = quantity <= dupl->quantity ? quantity : dupl->quantity; + const int sellCount = quantity <= dupl->quantity + ? quantity : dupl->quantity; dupl->quantity -= sellCount; mQuantity -= sellCount; if (dupl->quantity == 0) -- cgit v1.2.3-60-g2f50