-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexpense.h
65 lines (56 loc) · 1.59 KB
/
expense.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#pragma once
// Expense "class"
// day: int
// amount: int
// type: string (char[20])
typedef struct{
int day;
int amount;
char* type;
} Expense;
// Expense constructor
// day: int
// amount: int
// type: string (char[])
// returns struct Expense
Expense* expense_construct(const int day, const int amount, const char* type);
/**
* \brief Frees the memory allocated for the expense
* \param e: Expense* - the expense to be freed
*/
void expense_destruct(Expense* e);
/**
* \brief Prints an expense
* \param e: Expense* - the expense to be printed
*/
void print_expense(const Expense* e);
/**
* \brief Checks if the given expense has valid parameters
* \param e the expense that needs to be validated
* \return true if the expense is valid, false if contrary
*/
int expense_is_valid(const Expense* e);
/**
* \brief Sets a new day for the expense
* \param e the expense whose day will be modified
* \param new_day the new day
*/
void expense_set_day(Expense* e, const int new_day);
/**
* \brief Sets a new amount for the expense
* \param e the expense whose amount will be modified
* \param new_amount the new amount
*/
void expense_set_amount(Expense* e, const int new_amount);
/**
* \brief Sets a new type for the expense
* \param e the expense whose type will be modified
* \param new_type the new type
*/
void expense_set_type(Expense* e, const char* new_type);
/**
* \brief Creates and returns a deep copy of an expense
* \param source_expense the expense whose contents will be copied
* \return the deep copy of source expense
*/
Expense* expense_deep_copy(const Expense* source_expense);