#include <iostream>

using std::endl;
using std::cout;
using std::cin;

class clSortClass
{
 char *cAccount;
 char *cAddress;
 char *cCardID;
 char *cPassword;
 
public:
 //Basic
 clSortClass(); 
 ~clSortClass();
 // 계좌번호 정렬 클래스
 bool cAccount_Sort_Init(char *_cAccount);
 bool cAccount_View(void);

 bool cAddress_Sort_Init(char *_cAddress);
 bool cAddress_View(void);

 bool cCardID_Sort_Init(char *_cCardID);
 bool cCardID_View(void);

 bool cPassword_Sort_Init(char *_cPassword);
 bool cPassword_View(void);
};

clSortClass::clSortClass()
{
 cAccount=new char[19]; // 계좌18자리 + NULL 1자리
 cAddress=NULL;
 cCardID=new char[17];  // CARD ID 16자리 +NULL 1자리
 cPassword=new char[5]; // 비밀번호 4자리 +NULL 1자리
 cout <<"***********************n"
  <<" Sort Class 생성 완료  n"
  <<"***********************n"<<endl;
}

clSortClass::~clSortClass()
{
 if(cAccount!=NULL)
  delete cAccount; 
 if(cAddress!=NULL)
  delete cAddress;
 if(cCardID!=NULL)
  delete cCardID; 
 if(cPassword!=NULL)
  delete cPassword;
 cout <<"***********************n"
   <<" Sort Class 소멸 완료  n"
   <<"***********************n"<<endl;
}

bool clSortClass::cAccount_Sort_Init(char *_cAccount)
{
 int SL=strlen(_cAccount);  //문자열의 길이 저장
 for(int Point=0, AcVal=0; Point<SL; Point++)  // 숫자만 cAccount변수에 대입함.
 {
  if(47<_cAccount[Point] && _cAccount[Point]<58) // 0~9
  {
   cAccount[AcVal]=_cAccount[Point];
   AcVal++;
   if(AcVal==18)
   {
    cAccount[AcVal]=NULL;
    cout <<"***********************n"
      <<" 계좌 정렬 : "<<cAccount 
      <<"n***********************n"<<endl;
    return true;
   }
  }
 }
 return false;
}

bool clSortClass::cAccount_View(void)
{
 cout <<"***********************n";
 cout <<" 계좌 출력 : ";
 for(int Point=0; Point<19; Point++)
 {
  if(3<Point && Point<17)
   if(Point%4==0)
    cout <<"-";
  cout <<cAccount[Point];
 }
 cout <<endl;
 cout <<"***********************n"<<endl;
 return true;
}

bool clSortClass::cAddress_Sort_Init(char *_cAddress)
{
 int SL=strlen(_cAddress)+1;
 cAddress=new char[SL];
 for(int Point=0,AcVal=0 ; Point<SL; Point++)
 {
  if(_cAddress[Point]==' ')
   cAddress[AcVal]='_';
  else
   cAddress[AcVal]=_cAddress[Point];
  AcVal++;
 }

 cout <<"***********************n";
 cout <<" 주소 정렬 : ";
 for(int Point=0; Point<SL; Point++)
 {
  cout <<cAddress[Point];
 }
 cout <<endl;
 cout <<"***********************n"<<endl;


 return true;
}

bool  clSortClass::cAddress_View(void){
 int SL=strlen(cAddress);
 cout <<"***********************n";
 cout <<" 주소 출력 : ";
 for(int Point=0; Point<SL; Point++)
 {
  if(cAddress[Point]=='_')
  {
   cout <<" ";
   continue;
  }
  cout <<cAddress[Point];
 }
 cout<<endl;
 cout <<"***********************n"<<endl;
 return true;
}

bool clSortClass::cCardID_Sort_Init(char *_cCardID)
{
 int SL=strlen(_cCardID);
 for(int Point=0,AcVal=0 ; Point<SL; Point++)
 {
  if(47<_cCardID[Point] && _cCardID[Point]<58) // 0~9
  {
   cCardID[AcVal]=_cCardID[Point];
   AcVal++;
   if(AcVal==16) // 16자리 + NULL이므로
   {
    cCardID[AcVal]=NULL;
    cout <<"***********************n"
      <<" 카드 정렬 : "<<cCardID
      <<"n***********************n"<<endl;
    return true;
   }
  }
 }
 return false;
}
bool clSortClass::cCardID_View(void)
{
 cout <<"***********************n";
 cout <<" 카드 출력 : ";
 for(int Point=0; Point<16; Point++)
 {
  if(3<Point && Point<15)
   if(Point%4==0)
    cout <<"-";
  cout <<cCardID[Point];
 }
 cout <<endl;
 cout <<"***********************n"<<endl;
 return true;
}

bool clSortClass::cPassword_Sort_Init(char *_cPassword)
{
 int SL=strlen(_cPassword);
 for(int Point=0,AcVal=0 ; Point<SL; Point++)
 {
  if(47<_cPassword[Point] && _cPassword[Point]<58) // 0~9
  {
   cPassword[AcVal]=_cPassword[Point];
   AcVal++;
   if(AcVal==4) // 4자리 + NULL이므로
   {
    cPassword[AcVal]=NULL;
    cout <<"***********************n"
      <<" 비번 정렬 : "<<cPassword
      <<"n***********************n"<<endl;
    return true;
   }
  }
 }
 return false;
}
bool clSortClass::cPassword_View(void)
{
 int SL=strlen(cPassword);
 cout <<"***********************n";
 cout <<" 비번 출력 : ";
 for(int Point=0; Point<SL; Point++)
 {
  cout <<cPassword[Point];
 }
 cout <<endl;
 cout <<"***********************n"<<endl;
 return true;
}

int main(void)
{
 clSortClass Sort;

 if(Sort.cAccount_Sort_Init("3234-에헤헿1234방귀대장 뿡뿡이1234크레이지 쏘핫1234버닝투나이잇*_*12")) Sort.cAccount_View();

 if(Sort.cAddress_Sort_Init("네시 맹구 황동 투기아파트 금은동 강백호")) Sort.cAddress_View();
 if(Sort.cCardID_Sort_Init("1234-ㅁㄴㅇㄹ1234-1234-1234")) Sort.cCardID_View();

 if(Sort.cPassword_Sort_Init("1개떡같이 입력해도s2t3찰떡같이 소팅한다a6끼얏호7742")) Sort.cPassword_View();

 return 0;
}

번호 제목 글쓴이 날짜 조회 수
29 [CPP] file 입출력 : space data file simpled 2013.06.23 5271
28 [CPP] 1차 방정식을 통한 y값 구하기 simpled 2013.06.23 5790
27 [CPP] Vector 계산 클래스 (v2.0) file simpled 2013.06.23 4687
26 [CPP] 자리수 표현 simpled 2013.06.23 5633
25 [CPP] 각도 클래스(+ 아크탄젠트 리턴값 조정) file simpled 2013.06.23 6040
24 [CPP] 벡터 계산 클래스 file simpled 2013.06.23 6103
23 [CPP] file 입출력 simpled 2013.06.23 4977
22 [CPP] 수치해석 : Rectangle Method 구분구적분 (적분 프로그래밍) simpled 2013.06.23 8124
21 [CPP] 분포하중 _ Beam의 SFD, BMD 값 simpled 2013.06.23 6488
20 [CPP] OOP6. CPP Programming :: Virtual Banking system PPT [끝] file 심플디 2013.06.23 6623
19 [CPP] OOP6. CPP Programming :: Virtual Banking system v3.8 file simpled 2013.06.23 5933
18 [CPP] OOP6. CPP Programming :: Virtual Banking system 모듈프로그램들 file simpled 2013.06.23 5257
17 [CPP] OOP6. CPP Programming :: Virtual Banking system v3.7 file simpled 2013.06.23 5967
16 [CPP] OOP6. CPP Programming :: Virtual Banking system v3.6 file simpled 2013.06.23 6304
15 [CPP] OOP6. CPP Programming :: Virtual Banking system v3.5.1 file simpled 2013.06.23 6456
14 [CPP] OOP6. CPP Programming :: Virtual Banking system v3.5 file simpled 2013.06.23 6635
13 [CPP] -----------------------------------절취선----------------------------------- simpled 2013.06.23 5843
12 [CPP] Banksys 휴식 simpled 2013.06.23 6510
» [CPP] OOP5. CPP Programming :: Virtual Banking system v3.0.2 [Class design3. String Sorting] simpled 2013.06.23 5627
10 [CPP] OOP5. CPP Programming :: Virtual Banking system v3.0.2 [Class design2. File I/O] simpled 2013.06.23 6563