I finished the lab, and everything works, but I just don't like the way it looks...a bit disjointed to my eye. I'm happy that it works, but I want to write robust, readable code as well as functional. So, if you're interested (have spare time) would you take a look at the file and leave constructive feedback for improvement please?

MainDriver

#include <iostream>
#include <iomanip>
#include <string>

// User-defined headers
#include "MediaCollection.h"

// Global function definitions
void DisplayMenu();

using namespace std;

void main()
{
// Create my media collection
MediaCollection MediaCollection;

// Declare and initialize the variable used for the menu
int menuChoice = 0;

do
{
cout << endl << "Welcome to the " << MediaCollection.getCollectionName()
<< " Media Collection Menu. Select from the following choices:" << endl << endl;

// Display the menu of choices
DisplayMenu();

menuChoice = MediaCollection.MenuSelection();

switch (menuChoice)
{
case 1:
MediaCollection.addMedia();
break;
case 12:
cout << "Terminating program... Have a great day!" << endl;
break;
default:
cout << "Invalid choice. Please select again.";
}
}
while(menuChoice != 12);

// Wait for user input before terminating program
system("PAUSE");
}
#include <iostream>
#include <iomanip>
#include <string>
// User-defined headers
#include "MediaCollection.h"

using namespace std;

// Global function definitions
void DisplayMenu();

int main()
{
     // Create my media collection
     MediaCollection MediaCollection;

     // Declare and initialize the variable used for the menu
     int menuChoice = 0;

     do{

          cout << endl << "Welcome to the " << MediaCollection.getCollectionName()
               << " Media Collection Menu. Select from the following choices:" 
               << endl << endl;

          // Display the menu of choices
          DisplayMenu();

          menuChoice = MediaCollection.MenuSelection();

          switch (menuChoice)
          {
               case  1:  MediaCollection.addMedia();
               break;
               case 12:  cout << "Terminating program... Have a great day!" << endl;
               break;
               default:  cout << "Invalid choice. Please select again.";
               break;
          }
     }while(menuChoice != 12);

     // Wait for user input before terminating program
     cin.get();

     return 0;
}

void main() is bad. why? it's non-compliant with the ISO c++ standard which states a program that terminates successfully must return 0 (EXIT_SUCCESS) to the operating system. why? so the operating system knows your program exited successfully. why? so your operating system doesn't have to generate and send a microsoft system error report for analysis when the operating system is fine and it's just your junkie code causing the problem.

Edited 6 Years Ago by Clinton Portis: n/a

This article has been dead for over six months. Start a new discussion instead.