-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAlgorithmFactory.h
More file actions
37 lines (34 loc) · 1.12 KB
/
AlgorithmFactory.h
File metadata and controls
37 lines (34 loc) · 1.12 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
/**
* Authors: Alysha Aul, Nandhitha Krishnan, Paul Rodgers, Nouran Sakr, Chun Yang
* Date: November 7, 2023
* Purpose: Creates a factory class to store different pathfinding algorithms for use on the board
*/
#ifndef ALGORITHMFACTORY_H
#define ALGORITHMFACTORY_H
#include "Dijkstra.h"
#include "AStar.h"
/**
* Factory for creating the pathfinding algorithm instance
* @param type: Integer presenting algorithm type (0 for Disjkstra(default), 1 for AStar)
* @param board: Pointer reference to current board
* @return instance: An instance of the selected algorithm
*/
class AlgorithmFactory {
public:
Algorithm* createAlgorithmInstance(int type, Board* board) {
Algorithm* instance;
switch(type) {
case 0:
instance = new Dijkstra(board);
break;
case 1:
instance = new AStar(board);
break;
default:
instance = new Dijkstra(board);
break;
}
return instance;
}
};
#endif