|
질문 제목 : 계좌 프로그램 만들기
질문 요약 :
클래스 치환 이용해서 계좌 프로그램을 짜고있는데요
최대 등록가능한 인원을 5명으로잡고
이름하고 학번을 입력 받아서
계좌 번호를 생성하는 건데
계좌번호는 (2000000000+학번)으로 생성 했어요 .
여기서 빨간 부분에 입력함수하고 출력함수 호출하고
입력 받은걸 클래스치환 이용해서 저장 목록에 추가하는걸 해야하는데 좀 알려주세요 ㅜㅜ
질문 내용 : #include <iostream>
using namespace std;
#define MAX 5 // 등록가능한 최대인원
//*************************>> class 선언
//data 초기화, 출력 class
class Person
{
private:
char* name; //이름
int id; //학번
int account; //계좌번호 (2000000000+학번)으로 생성
public:
Person(){}; //생성자 초기화
Person(char* tname, int id); //name, id, account 생성자 초기화
void Printdata(int f, int num); //name, id, account 출력
};
Person::Person(char* tname, int tid) //생성자 초기화
{
name=new char[strlen(tname)+1]; //name 동적할당
strcpy(name,tname);
id=tid;
account = 2000000000; //account 초기화
account += id;
}
//data 입력, continue, exit class
class Operator
{
public:
Person Getdata(); //name, id 입력
int Continue(int num); //계속할지 여부 결정
void Exit(void); //End
};
int Operator::Continue(int num)
{
int con;
cout<<'\n'<<"Continue? 1.YES 2.NO ____ ";
cin>>con;
if(con==1)
{
if(num<MAX)
return 1;
else
{
cout<<"등록 가능한 최대인원("<<MAX<<"명)을 초과하였습니다."<<endl;
return 0;
}
}
else
return 0;
}
void Operator::Exit(void)
{
cout<<'\n'<<"프로그램을 종료합니다"<<'\n';
}
//*************************>> main문
void main(void)
{
int num=0; //입력한 인원 명수
int flag=1; //더 입력할지에 관한 플래그
Person inputman; //입력 data
Person man[MAX]; //입력 받은 data들의 저장목록 (최대 5개)
Operator oper; //operator class
while(flag)
{
Operator::Person Getdata();
char* name; 여기 입력함수 호출하고 그 다음 출력 함수 호출 해서
int id; 클래스 치환으로 입력 된 정보를 저장해서
cout<<"*계좌 개설*"<<endl;
cout<<"<정보를 입력해 주세요>"<<endl;
cout<<"Name : ";
cin>>name;
cout<<"학번: ";
cin>>id;
cout<<"<1>번째 등록 내용입니다."<<endl;
return
num++;
flag=oper.Continue(num);
cout<<'\n';
}
cout<<"============================================================="<<endl;
cout<<'\n'<<"<등록된 모든 계좌는 다음과 같습니다.>"<<endl;
cout<<" 이름"<<'\t'<<" 학번 "<<'\t'<<" 계좌번호 "<<endl;
///////////////
//전체 정보 출력함수 호출 여기 전체 정보 출력함수 호출하고 등록된 정보를 호출해야하거든요 ㅜㅜ
///////////////
cout<<"============================================================="<<endl;
oper.Exit();
}
아래 첨부 파일과 같이 출력을 해야해요 ㅜㅜ
|