44 lines
662 B
C
44 lines
662 B
C
|
#ifndef __CONTEXT_H__
|
|||
|
#define __CONTEXT_H__
|
|||
|
|
|||
|
#include "Strategy.h"
|
|||
|
#include <stdio.h>
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
class Context
|
|||
|
{
|
|||
|
public:
|
|||
|
Context(){
|
|||
|
arr = NULL;
|
|||
|
N = 0;
|
|||
|
}
|
|||
|
Context(int iArr[], int iN){
|
|||
|
this->arr = iArr;
|
|||
|
this->N = iN;
|
|||
|
}
|
|||
|
void setSortStrategy(Strategy* iSortStrategy){
|
|||
|
this->sortStrategy = iSortStrategy;
|
|||
|
}
|
|||
|
void sort(){
|
|||
|
this->sortStrategy->sort(arr, N);
|
|||
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ");
|
|||
|
this->print();
|
|||
|
}
|
|||
|
void setInput(int iArr[], int iN){
|
|||
|
this->arr = iArr;
|
|||
|
this->N = iN;
|
|||
|
}
|
|||
|
void print(){
|
|||
|
for (int i = 0; i < N; i++){
|
|||
|
printf("%3d ", arr[i]);
|
|||
|
}
|
|||
|
printf("\n");
|
|||
|
}
|
|||
|
|
|||
|
private:
|
|||
|
Strategy* sortStrategy;
|
|||
|
int* arr;
|
|||
|
int N;
|
|||
|
};
|
|||
|
|
|||
|
#endif // __CONTEXT_H__
|