void DoPrint(string classes[5][], size_t sizes[5], string className){
if (className=='A') {
PrintArray(classes[0],size[0])
} else if (className == 'B') {
PrintArray(classes[1],size[1])
} else if (className == 'C') {
PrintArray(classes[2],size[2])
...
}
}
void DoLoad(string classes[5][], size_t sizes[5], string className, string filename){
if (className=='A') {
LoadArray(classes[0],size[0], filename)
} else if (className == 'B') {
LoadArray(classes[1],size[1], filename)
} else if (className == 'C') {
LoadArray(classes[2],size[2], filename)
...
}
Instead, do the following
size_t IndexFromName(string className){
size_t rv = MAX_CLASSES;
if (className == "A") {
rv = 0;
} else if (className == "B") {
rv = 1;
...
}
return rv;
}
void DoPrint(string classes[5][], size_t sizes[5], string className){
index = IndexFromName(className);
if (index < MAX_CLASSES):
PrintArray(classes[index],size[index])
} else {
// error message about class name
}
void DoLoad(string classes[5][], size_t sizes[5], string className, string filename){
index = IndexFromName(className);
if (index < MAX_CLASSES):
LoadArray(classes[index],size[index], filename)
} else {
// error message about class name
}