74 lines
2.2 KiB
C++
74 lines
2.2 KiB
C++
#ifndef __COOKIES_H__
|
|
#define __COOKIES_H__
|
|
|
|
#include <string>
|
|
using namespace std;
|
|
|
|
const int MAXIMUM_SIZE = 10;
|
|
|
|
/*
|
|
addOrder
|
|
|
|
Adds the memory address of a new string to the given array. The new string should have the
|
|
same data as that of the given string.
|
|
|
|
A string may already exist containing the same data as the given string (ie, the string
|
|
passed to this function as a parameter) and whose memory address is already stored within
|
|
the given array. In this situation, add to the array the memory address of the string that
|
|
already exists rather than creating a new string.
|
|
|
|
Update the reference of size appropriately.
|
|
*/
|
|
void addOrder(string * cookies[], int * size, string new_name);
|
|
|
|
|
|
/*
|
|
deliverOrder
|
|
|
|
Removes all references to strings containing the same data as the given string and reports
|
|
the number of string references removed. The overall order of the list is unchanged.
|
|
|
|
Update the reference of size appropriately.
|
|
*/
|
|
int deliverOrder(string * cookies[], int * size, string name);
|
|
|
|
|
|
/*
|
|
modifyOrder
|
|
|
|
Searches the given array for a memory address to a string that contains the same data as the
|
|
first given string.
|
|
|
|
If found, the data of the found string is changed to match the data of the second given string,
|
|
and the function returns true. If not found, the function returns false.
|
|
*/
|
|
bool modifyOrder(string * cookies[], int * size, string original_name, string new_name);
|
|
|
|
|
|
/*
|
|
displayOrders
|
|
|
|
Returns a string containing a list of names referred to in the given array.
|
|
Each index in the array represents a particular box of cookies, and there may be more than
|
|
one box for each customer. Therefore, this function's output may include the same name
|
|
multiple times.
|
|
*/
|
|
string displayOrders(string * cookies[], int * size);
|
|
|
|
|
|
/*
|
|
findOrder
|
|
|
|
Returns a memory address found in the given array that references a string with the same data
|
|
as the given string. Returns null if no such string is found.
|
|
|
|
It is recommended that you use this function within your other functions. If you do not, you
|
|
must still complete this function as described above.
|
|
*/
|
|
string * findOrder(string * cookies[], int * size, string name);
|
|
|
|
void clean_up(string * cookies[], int * size);
|
|
|
|
#endif
|
|
|