Galera, boa tarde.
Estou precisando transformar o código abaixo que está em PE (Programação Estruturada) para POO (Programação Orientada a objeto).
Ou seja, temos que criar uma classe (um arquivo .h, usar o destrutor e construtotor, set e get) e chamar no #include.
em Paralelo, temos que substituir o insert sort por um método bubble sorte.
SERÁ QUE ALGUÉM PODE ME AJUDAR ?
Segue o código em C++ que deve ser transformado para POO.
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std ;
void buildArray( char [ ] , int ) ;
void sortArray( char [ ] , int ) ;
void printArray( const char [ ] , int ) ;
int main( )
{
const int aSize = 20 ;
char a[ aSize ] ;
buildArray( a , aSize ) ;
sortArray( a , aSize ) ;
printArray( a , aSize ) ;
return 0 ;
}
void buildArray( char b[ ] , int bSize )
{
srand( time( 0 ) ) ;
for ( int i = 0 ; i < bSize ; ++i )
b[ i ] = (char)(rand( ) % 95 + 33) ;
}
void sortArray( char b[ ] , int bSize )
{
for ( int j = 1 ; j < bSize ; ++j )
{
int ins = b[ j ] ;
int mov = j ;
while ( ( mov > 0 ) && ( b[ mov - 1 ] > ins ) )
{
b[ mov ] = b[ mov - 1 ];
mov--;
}
b[ mov ] = ins ;
}
}
void printArray( const char b[ ] , int bSize )
{
cout << endl ;
for ( int i = 0 ; i < bSize ; ++i )
cout << b[ i ] << " " ;
cout << endl ;
}
Código em PE.txt