Skip to main content
added 182 characters in body
Source Link
phil
  • 199
  • 6

this partThe parts where you set up the alphabet of each rotor has a lot more boilerplate than it should.

rotor[i] = 'Z';
i++;
... //Rest of letters
rotor[i]

Could be changed to this:

rotor = 'Z';
i++;new char[] { 'Z', \* Rest of letters and such *\ };

You should useIt is basically the array initialization syntax.

rotor = new char[] { ' ', 'A'same idea, ..but it is more readable. };

It actually is there a reason you can't dobetter performance because it this way?eliminates the incrementing of i

this part

... //Rest of letters
rotor[i] = 'Z';
i++;

You should use the array initialization syntax.

rotor = new char[] { ' ', 'A', ... };

is there a reason you can't do it this way?

The parts where you set up the alphabet of each rotor has a lot more boilerplate than it should.

rotor[i] = 'Z';
i++;
... //Rest of letters

Could be changed to this:

rotor = new char[] { 'Z', \* Rest of letters and such *\ };

It is basically the same idea, but it is more readable. It actually is better performance because it eliminates the incrementing of i

Source Link
phil
  • 199
  • 6

this part

... //Rest of letters
rotor[i] = 'Z';
i++;

You should use the array initialization syntax.

rotor = new char[] { ' ', 'A', ... };

is there a reason you can't do it this way?