View Single Post
Old 06-24-2004, 07:00 AM   #4 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
Testing error while posting code. Don't know what's wrong.
Code:
// ****** Main.cpp ******

#include "SortingMachine.h"
#include "SortStrategy.h"
#include "AscendSort.h"
#include "DescendSort.h"
#include <iostream>
#include <string>
#include <cassert>

using namespace std;
int main()
{
 string sortedString[] = { "a", "b", "c" };

   SortingMachine* sm = new SortingMachine;
   sm->SetArray( sortedString, 3 );

	 sm->SetSortStrategy( new AscendSort );
   assert( sm->IsSorted() );
 
   sm->SetSortStrategy( new DescendSort );
   assert( !sm->IsSorted() );

   delete sm;
for(int i=0 ; i<3 ; ++i)
   cout<<sortedString[i]<<endl;

cout<<"OK"<<endl;
return EXIT_SUCCESS;
}
__________________
Valmont is offline   Reply With Quote