forked from Danielbet21/Amusement_Park
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTicket.h
50 lines (39 loc) · 1.47 KB
/
Ticket.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
#ifndef __TICKET__
#define __TICKET__
#include <crtdbg.h> // TODO: remove before release
#include <stdio.h>
#include <string.h>
#include "Date.h"
#include "General.h"
#include "fileHelper.h"
#define ID_TICKET_LEN 12
#define BASE_TICKET_PRICE 100.0
#define CURRENCY_SYMBOL "$" // because ¤ doesn't work in the terminal ):
typedef enum {
eChild, eAdult, eStudent, eSoldier, eNofTicketTypes
} eGuestType;
static const char* TicketTypeStr[eNofTicketTypes] = { "Child", "Adult", "Student", "Soldier" };
static const double Discount[eNofTicketTypes] = { 0.5, 1, 0.77, 0.0 };
typedef struct {
char id[ID_TICKET_LEN + 1]; // + 1 for null terminator
eGuestType guestType;
double price;
int isUsed;
Date dateOfVisit;
} Ticket;
int initTicket(Ticket* ticket, eGuestType guestType, Date dateOfVisit);
void generateID(char* id);
int isValidTicket(eGuestType guestType, Date dateOfVisit);
void printTicket(const void* ticket);
void printTicketWrapper(const void* ticket);
int compareTicketsByID(const void* ticket1, const void* ticket2);
int compareTicketsByDate(const void* ticket1, const void* ticket2);
int compareTicketsByGuestType(const void* ticket1, const void* ticket2);
void printGuestType();
void initTicketByUser(Ticket* ticket);
// save and load functions
int saveTicketToTextFile(const Ticket* ticket, FILE* fp);
int loadTicketFromTextFile(Ticket* ticket, FILE* fp);
int saveTicketToBinFile(const Ticket* ticket, FILE* fp);
int loadTicketFromBinFile(Ticket* ticket, FILE* fp);
#endif