I am trying to make a simulation of the enigma machine and was wondering if this is the right way to start the problem?

Here's the main.cpp file:

#include <iostream>
#include <ctime>
#include <cmath>
#include "enigma.h"
using namespace std;

int main ()
{
    enigma machine_1;

    return 0;
}

Here's the enigma.h file:

#include <iostream>
#include <string>
#include <vector>
#include <ctime>
#include <cmath>
using namespace std;

class plug_board
{
  private:

  public:
	plug_board()
	{
		cout << "new plug_board" << endl;
	}
	~plug_board()
	{
		cout << "plug_board gone" << endl;
	}
};

class reflector
{
  private:

  public:
	reflector()
	{
		cout << "new reflector" << endl;
	}
	~reflector()
	{
		cout << "reflector gone" << endl;
	}
};

class rotor
{
  private:

  public:
	rotor()
	{
		cout << "new rotor" << endl;
	}
	~rotor()
	{
		cout << "rotor gone" << endl;
	}
};

class enigma
{
  private:

  public:
	enigma()
	{
		cout << "new enigma" << endl;
		plug_board board_1;
	  reflector reflect_1;
	  rotor roto_1;
		rotor roto_2;
		rotor roto_3;
	}
	~enigma()
	{
		cout << "enigma gone" << endl;
	}
};

Any help or suggestions will be greatly appreciated.

class enigma
{
  private:

  public:
	enigma()
	{
		cout << "new enigma" << endl;
		plug_board board_1;
	  reflector reflect_1;
	  rotor roto_1;
		rotor roto_2;
		rotor roto_3;
	}
	~enigma()
	{
		cout << "enigma gone" << endl;
	}
};

if the plug_board , reflector and rotor are the composites of the enigma then you have the declare them as member variables.
This way their destructors will be called when you reach outside the
constructor.

And inside the destructor you can destroy those initialized objects if
you initialize them using the 'new' keyword.

The design depends on how it will be used. Write a driver (a main) that uses the object's interface AS IF it was already written. Then create a class for an object that fits that interface. It also depends on how much detail you want in the simulation. If you wished you could model it right down to the wires.

I want to use this simulation to model the real enigma as much as possible. I am just doing this project as a way to get better acquainted with OOP.

I guess this is what you are trying to tell me.

main.cpp:

int main ()
{
    enigma machine_1;
    plug_board board_1;
    reflector reflect_1;
    rotor roto_1;
    rotor roto_2;
    rotor roto_3;

    machine_1.encrypt();

    return 0;
}

I should declare the classes in the main so that I can actually manipulate them while they are created.

Remember what NicAx64 said, that the plugboard etc belong as data members within the Enigma class. So something like this:

class Enigma {

    PlugBoard plugBoard;
    Reflector reflector;
    Rotor rotor[3];

public:

    Enigma();
    // ...

    string encrypt(string plainText);
    string encrypt(char* plainText);

    string decrypt(string cipherText);
    string decrypt(char* cipherText);
};

int main() {

    Enigma machine;

    string msg("Hello world");
    cout << msg;

    string cipher = machine.encrypt(msg);
    cout << cipher;

    string plain = machine.decrypt(cipher);
    cout << plain;
}
This question has already been answered. Start a new discussion instead.