-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathitem.cpp
More file actions
50 lines (44 loc) · 1.42 KB
/
Copy pathitem.cpp
File metadata and controls
50 lines (44 loc) · 1.42 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
38
39
40
41
42
43
44
45
46
47
48
49
50
//---------------------------------------------------------------------------
// item.h
//---------------------------------------------------------------------------
// An abstract class.
// An item class for the library to store different types of items.
// Current item types are book, but can be other types such as DVD, magazine,
// etc.
//
// Assumptions:
// -- All items will have a unique char identifier
// -- all items will have a format
//
// Implementation:
// -- bool array keeps track of known formats
//
//---------------------------------------------------------------------------
#include "item.h"
using namespace std;
//---------------------------------------------------------------------------
// constructor
Item::Item() {
itemType_ = ' ';
// initialize known formats
validFormat[7] = true;
}
//---------------------------------------------------------------------------
// destrucor
Item::~Item() {}
//---------------------------------------------------------------------------
// getType
char Item::getType() const { return itemType_; }
//---------------------------------------------------------------------------
// setFormat
bool Item::setFormat(char format) {
bool success = false;
if (format > 'A' && format < 'z') {
int checkHash = toupper(format) - 'A';
if (validFormat[checkHash]) {
format_ = format;
success = true;
}
}
return success;
}