-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathitem.cpp
More file actions
37 lines (34 loc) · 1.22 KB
/
item.cpp
File metadata and controls
37 lines (34 loc) · 1.22 KB
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
35
36
37
/* Aaron Parks
* Prof. Carol Zander
* CSS 343 : Winter 2010
* Lab 4v4 - MOVIE Store */
#include "item.h"
//------------------------------------------------------------------------------
// Constructor
// - Initializes data members of 'Item'. Necessary for constructors of dervied
// classes.
//------------------------------------------------------------------------------
Item::Item()
{
stock = INITIAL_STOCK;
borrowed = 0;
}
//------------------------------------------------------------------------------
// stockAdjustment
// - Will adjust 'stock' and 'borrowed' number according parameters. If either
// 'stock' or 'borrowed' cannot be adjusted, will return false. Otherwise,
// will return true;
//------------------------------------------------------------------------------
bool Item::stockAdjustment(int inStockAdj, int outStockAdj)
{
//trying to borrow more than the store stock
if (stock == 0 && outStockAdj > 0)
return false;
//trying return movies the store doesn't own
if (borrowed == 0 && inStockAdj > 0)
return false;
//make adjustments //parameters can be positive or negative
stock += inStockAdj;
borrowed += outStockAdj;
return true;
}