0% found this document useful (0 votes)
12 views

Message

Uploaded by

tongvythanh05
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Message

Uploaded by

tongvythanh05
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

/* Includes ------------------------------------------------------------------*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>

/* Define --------------------------------------------------------------------*/
#define MAX_ROW 2
#define MAX_COLUMN 15
#define MAX_ENTERPRISE 30

/* Enum ----------------------------------------------------------------------*/
typedef enum Status
{
Empty,
Registered
} Status;

typedef enum CommandType


{
REGISTER,
ALTER,
SHOW,
DELETE,
QUIT,
INVALID
} CommandType;

/* --------------------------------------------------------------------------- */
/* Begin: Student Answer */
/* --------------------------------------------------------------------------- */

// Requirement 1: Generate abbreviation from the full name of an enterprise


void getAbbreviation(char *name, char *abbre)
{
// TODO: Implement this function
}

// Requirement 2: Determine the type of command


CommandType getCommandType(char *command)
{
// TODO: Implement this function
}

// Requirement 3: Define the structure to store enterprise details


typedef struct
{
// TODO: Implement this function
} Enterprise;

// Requirement 4: Print the details of a specific enterprise


void printEnterpriseDetails(Enterprise e)
{
// TODO: Implement this function
}

// Requirement 5: Create an enterprise with specified values


void createEnterprise(Enterprise *e, int booth_index, int itemValue, int
itemWeight, char *name, char *abbre)
{
// TODO: Implement this function
}

// Requirement 6: Register an enterprise to a booth


void registerEnterprise(int map[MAX_ROW][MAX_COLUMN], Enterprise
enterpriseArray[MAX_ENTERPRISE],
char *name, int booth, int itemValue, int
itemWeight, int *out_booth, char *out_abbre)
{
// TODO: Implement this function
}

// Requirement 7: Display the booth map and status


void showMap(int map[MAX_ROW][MAX_COLUMN], Enterprise
enterpriseArray[MAX_ENTERPRISE])
{
// TODO: Implement this function
}

// Requirement 8: Show booth indexes based on their status


void showIndexOfStatus(int map[MAX_ROW][MAX_COLUMN], Status status)
{
// TODO: Implement this function
}

// Requirement 9: Show the total count of booths with a specific status


void showTotalOfStatus(Enterprise enterpriseArray[MAX_ENTERPRISE], Status status)
{
// TODO: Implement this function
}

// Requirement 10: Display details of booths in a specified range


void showIndexBracket(int map[MAX_ROW][MAX_COLUMN], Enterprise
enterpriseArray[MAX_ENTERPRISE], int start, int end)
{
// TODO: Implement this function
}

// Requirement 11: Handle the "Show" command and call the appropriate function
void handleShowCommand(int map[MAX_ROW][MAX_COLUMN], Enterprise
enterpriseArray[MAX_ENTERPRISE], char *command)
{
// TODO: Implement this function
}

// Requirement 12: Alter the booth assignment for a specified enterprise


void alterEnterprise(int map[MAX_ROW][MAX_COLUMN], Enterprise
enterpriseArray[MAX_ENTERPRISE], char *abbre,
int registerBooth, int newBooth, int *out_booth,
char *out_abbre)
{
// TODO: Implement this function
}

// Requirement 13: Delete an enterprise from the system


void deleteEnterprise(int map[MAX_ROW][MAX_COLUMN], Enterprise
enterpriseArray[MAX_ENTERPRISE], char *abbre, int booth, int *totalEmpty)
{
// TODO: Implement this function
}

// Requirement 14: Process commands and call the relevant function


void handleCommand(char *command, int map[MAX_ROW][MAX_COLUMN], Enterprise
enterpriseArray[MAX_ENTERPRISE], CommandType *commandType)
{
// TODO: Implement this function
}

// Requirement 15: Optimize items collected using the knapsack algorithm


int knapsack(int map[MAX_ROW][MAX_COLUMN], Enterprise
enterpriseArray[MAX_ENTERPRISE],
int maxWeight, int numOfEnterprises, int index)
{
// TODO: Return the maximum value collected
}

/* --------------------------------------------------------------------------- */
/* End: Student Answer */
/* --------------------------------------------------------------------------- */

/* --------------------------------------------------------------------------- */
/* Example Test Cases for Main */
/* --------------------------------------------------------------------------- */

// Initializes booth map and enterprise array to default values and then
// runs a series of test cases to verify enterprise registration, booth
// assignments, alterations, and knapsack optimization functionality.

// Initialize the booth map with default status Empty


void initMap(int map[MAX_ROW][MAX_COLUMN])
{
for (int i = 0; i < MAX_ROW; i++)
{
for (int j = 0; j < MAX_COLUMN; j++)
{
map[i][j] = Empty;
}
}
}

// Initialize the enterprise array with default values


void initEnterpriseArray(Enterprise enterpriseArray[MAX_ENTERPRISE])
{
for (int i = 0; i < MAX_ENTERPRISE; i++)
{
enterpriseArray[i].booth_index = -1;
strcpy(enterpriseArray[i].name, "");
strcpy(enterpriseArray[i].abbre, "");
enterpriseArray[i].itemValue = 0;
enterpriseArray[i].itemWeight = 0;
}
}

int main()
{
// Define your own testcases to test by yourself
return 0;
}

You might also like