-
Notifications
You must be signed in to change notification settings - Fork 0
/
library1.cpp
114 lines (102 loc) · 5.49 KB
/
library1.cpp
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#include "library1.h"
#include "utility.h"
/* Description: Initiates the data structure.
* Input: DS - A pointer to the data structure.
* Output: None.
* Return Values: A pointer to a new instance of the data structure - as a void* pointer.
*/
void* Init();
/* Description: Adds a new trainer.
* Input: DS - A pointer to the data structure.
* trainerID - The ID of the trainer to add.
* Output: None.
* Return Values: ALLOCATION_ERROR - In case of an allocation error.
* INVALID_INPUT - If DS==NULL or if trainerID <= 0.
* FAILURE - If trainerID is already in the DS.
* SUCCESS - Otherwise.
*/
StatusType AddTrainer(void *DS, int trainerID);
/* Description: Adds a new gladiator to the system.
* Input: DS - A pointer to the data structure.
* gladiatorID - ID of the gladiator to add.
* trainerID - The ID of the gladiator's trainer
* level - The gladiator's level
* Output: None.
* Return Values: ALLOCATION_ERROR - In case of an allocation error.
* INVALID_INPUT - If DS==NULL, or if gladiatorID <=0, or if trainerID <=0, or if level <= 0
* FAILURE - If gladiatorID is already in the DS, or trainerID isn't in the DS.
* SUCCESS - Otherwise.
*/
StatusType BuyGladiator(void *DS, int gladiatorID, int trainerID, int level);
/* Description: Removes an existing gladiator.
* Input: DS - A pointer to the data structure.
* gladiatorID - The ID of the gladiator to remove.
* Output: None.
* Return Values: ALLOCATION_ERROR - In case of an allocation error.
* INVALID_INPUT - If DS==NULL or if gladiatorID <= 0.
* FAILURE - If gladiatorID isn't in the DS.
* SUCCESS - Otherwise.
*/
StatusType FreeGladiator(void *DS, int gladiatorID);
/* Description: Increases the level of a gladiator.
* Input: DS - A pointer to the data structure.
* gladiatorID - The ID of the gladiator.
* levelIncrease - The increase in level.
* Output: None.
* Return Values: ALLOCATION_ERROR - In case of an allocation error.
* INVALID_INPUT - If DS==NULL, or if gladiatorID<=0, or if levelIncrease<=0
* FAILURE - If gladiatorID isn't in the DS.
* SUCCESS - Otherwise.
*/
StatusType LevelUp(void *DS, int gladiatorID, int levelIncrease);
/* Description: Upgrades a gladiator, updating his ID, while maintaining his level.
* Input: DS - A pointer to the data structure.
* gladiatorID - The original ID of the gladiator.
* upgradedID - The new ID of the gladiator.
* Output: None.
* Return Values: ALLOCATION_ERROR - In case of an allocation error.
* INVALID_INPUT - If DS==NULL, or if gladiatorID<=0, or if upgradedID<=0.
* FAILURE - If gladiatorID isn't in the DS, or upgradedID is in the DS.
* SUCCESS - Otherwise.
*/
StatusType UpgradeGladiator(void *DS, int gladiatorID, int upgradedID);
/* Description: Returns the gladiator with the highest level from trainerID
* If trainerID < 0, returns the top gladiator in the entire DS.
* Input: DS - A pointer to the data structure.
* trainerID - The trainer that we'd like to get the data for.
* Output: gladiatorID - A pointer to a variable that should be updated to the ID of the top gladiator.
* Return Values: ALLOCATION_ERROR - In case of an allocation error.
* INVALID_INPUT - If DS==NULL, or if gladiatorID == NULL, or if trainerID == 0.
* SUCCESS - Otherwise.
*/
StatusType GetTopGladiator(void *DS, int trainerID, int *gladiatorID);
/* Description: Returns all the gladiators from trainerID sorted by their level.
* If trainerID < 0, returns all the gladiators in the entire DS sorted by their level.
* Input: DS - A pointer to the data structure.
* trainerID - The trainer that we'd like to get the data for.
* Output: gladiators - A pointer to a to an array that you should update with the gladiators' IDs sorted by their level,
* in case two gladiators have same level they should be sorted by their ID.
* numOfGladiator - A pointer to a variable that should be updated to the number of gladiators.
* Return Values: ALLOCATION_ERROR - In case of an allocation error.
* INVALID_INPUT - If any of the arguments is NULL or if trainerID == 0.
* SUCCESS - Otherwise.
*/
StatusType GetAllGladiatorsByLevel(void *DS, int trainerID, int **gladiators, int *numOfGladiator);
/* Description: Updates the level of the gladiators where gladiatorID % stimulantCode == 0.
* For each matching gladiator, multiplies its level by stimulantFactor.
* Input: DS - A pointer to the data structure.
* stimulantCode - The basis that the stimulant works on
* stimulantFactor - The multiply factor of the level
* Output: None.
* Return Values: ALLOCATION_ERROR - In case of an allocation error.
* INVALID_INPUT - If DS==NULL or if stimulantCode < 1 or if stimulantFactor <1
* SUCCESS - Otherwise.
*/
StatusType UpdateLevels(void *DS, int stimulantCode, int stimulantFactor);
/* Description: Quits and deletes the database.
* DS should be set to NULL.
* Input: DS - A pointer to the data structure.
* Output: None.
* Return Values: None.
*/
void Quit(void** DS);