-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patha2ms2.c
More file actions
132 lines (116 loc) · 5.03 KB
/
a2ms2.c
File metadata and controls
132 lines (116 loc) · 5.03 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
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// ===================================================================================
//
// Assignment: 2
// Milestone: 2
// Description: Main
//
// +---------------------------------------------------------+
// | *** The contents of this file is NOT to be modified *** |
// +---------------------------------------------------------+
//
// ===================================================================================
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include "accountTicketingUI.h"
// -----------------------------------------------------------------------------------
// System Data Array sizes
// -----------------------------------------------------------------------------------
#define ACCOUNT_SIZE 5
#define TICKET_SIZE 20
// -----------------------------------------------------------------------------------
// Function Prototypes
// -----------------------------------------------------------------------------------
void populateAccounts(struct Account accounts[], int arrSize);
void populateTickets(struct Ticket tickets[], int arrSize);
// -----------------------------------------------------------------------------------
// Main: Entry-point to the application
// -----------------------------------------------------------------------------------
int main(void)
{
//----------------------------------------------
// Variables
//----------------------------------------------
struct Account accounts[ACCOUNT_SIZE] = { {0} };
struct Ticket tickets[TICKET_SIZE] = { {0} };
struct AccountTicketingData data = { accounts, ACCOUNT_SIZE, tickets, TICKET_SIZE };
//----------------------------------------------
// Populate the data arrays...
//----------------------------------------------
// setup some test accounts:
populateAccounts(data.accounts, data.ACCOUNT_MAX_SIZE);
// setup some test tickets:
populateTickets(data.tickets, data.TICKET_MAX_SIZE);
//----------------------------------------------
// launch application logic
//----------------------------------------------
applicationStartup(&data);
return 0;
}
// -----------------------------------------------------------------------------------
// Function Definitions
// -----------------------------------------------------------------------------------
void populateAccounts(struct Account accounts[], int arrSize)
{
int i, max = arrSize < 5 ? arrSize : 5;
struct Account tmp[5] = {
{ 30001, 'C', {"Silly Sally", 1990, 150000.10, "CANADA"}, {"", ""} },
{ 50599, 'A', {"Fred Flintstone", 1972, 2250400.22, "AFRICA"}, {"agent1", "yAb1#a@B"} },
{ 30004, 'C', {"Betty Boop", 1978, 250800.74, "INDIA"}, {"", ""} },
{ 50008, 'A', {"Will Smith", 1952, 2350600.82, "U.S.A."}, {"agentJ", "TT*&21tt"} },
{ 30020, 'C', {"Shrimpy Shrimp", 2000, 350500.35, "KOREA"}, {"", ""} }
};
// Copy test records
for (i = 0; i < max; i++)
{
accounts[i] = tmp[i];
}
}
void populateTickets(struct Ticket tickets[], int arrSize)
{
int i, max = arrSize < 5 ? arrSize : 5;
struct Ticket tmp[5] = {
// Ticket Test Record 1
{ 60001, 30004, 1, "Frequent Disconnects", 5,
// Ticket messages:
{ {'C', "Betty Boop", "Every time I go near the microwave the unit disconnects."},
{'A', "Will Smith", "Don't go near the microwave."},
{'C', "Betty Boop", "Well... that makes sense."},
{'A', "Will Smith", "Yup! :)"},
{'C', "Betty Boop", "Thanks - works now."}
}
},
// Ticket Test Record 2
{ 80599, 30001, 1, "No power/does not turn on", 1,
// Ticket messages:
{ {'C', "Silly Sally", "The unit won't turn on - please help."} }
},
// Ticket Test Record 3
{ 80004, 30020, 1, "My head hurts!", 3,
// Ticket messages:
{ {'C', "Shrimpy Shrimp", "When the unit is placed on my head it hurts."},
{'A', "Will Smith", "Don't place it on your head."},
{'C', "Shrimpy Shrimp", "I don't understand - why not?"}
}
},
// Ticket Test Record 4
{ 70533, 30004, 0, "Nothing happens...", 1,
// Ticket messages:
{ {'C', "Betty Boop", "Instructions state to 'say yes' to the prompts - but nothing happens."} }
},
// Ticket Test Record 5
{ 80020, 30020, 1, "It's broken/does not work", 5,
// Ticket messages:
{ {'C', "Shrimpy Shrimp", "When I took it out of the box, it's in pieces."},
{'A', "Fred Flintstone", "You have to assemble it - read the instructions."},
{'C', "Shrimpy Shrimp", "What are instructions?"},
{'A', "Fred Flintstone", "Well Shrimpy, I think you just made my day - that's funny!"},
{'C', "Shrimpy Shrimp", "Cool... but seriously what are instructions?"}
}
}
};
// Copy test records
for (i = 0; i < max; i++)
{
tickets[i] = tmp[i];
}
}