-
Notifications
You must be signed in to change notification settings - Fork 0
/
bookFactory.h
42 lines (37 loc) · 1.32 KB
/
bookFactory.h
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
/*
* bookFactory.h
* Authors: Camron Staley, Jessica Chann, Alex Christensen, KJ
*
* Class that represents a factory by using hashing to generate
* different product types
*
* Features:
* -- allows library system to create any subclass of type product
* -- subclasses currently include books
* -- book subclasses currently include fiction, youth, non-fiction
*
* Implementation and Assumptions:
* -- size defaults to number of capital ascii characters
* -- size should be changed when you add more subclasses
* -- hashing uses the type of book in a string
* -- string type should be unique to each product type
*
* Limitations:
*/
#pragma once
#include "factory.h"
#include "book.h"
#include "youth.h"
#include "periodical.h"
#include "fiction.h"
using namespace std;
//---------------------------------------------------------------------------
class BookFactory : public Factory {
public:
BookFactory(); // initializes the hashtable to the correct products
virtual ~BookFactory(); // sets pointers to null and deletes hash table
Book* createIt(char) const; // gets hash loc. and return prod.
private:
Book* bookFactory[hashTableSize]; // hashtable storing prod types
int hash(char ch) const { return ch; } // function uses product type to hash
};