|
http://www.hackerschool.org/HS_Boards/zboard.php?AllArticle=true&no=3046 [º¹»ç]
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
const int MAX_STD =2;
const int MAX_SBJ = 10;
class PersonalInformation {
int num;
char *name;
public:
PersonalInformation() {}
PersonalInformation(int n, char *name);
PersonalInformation(const PersonalInformation &inf);
void SetNum(int n) { num = n;}
void SetName(char *str);
int GetNum() {return num;}
char *GetName() {return name;}
void OutputData();
};
class Score : public PersonalInformation{//»ó¼Ó
int score[MAX_SBJ];
bool isInformation;
double average;
bool isScore;
public:
Score(){}
Score(int n, char *name) : PersonalInformation(n, name)
{isInformation = false;}
void SetScore(int i, int sc) {score[i] = sc;}
void SetIsInformation(bool i) {isInformation = i;}
void SetAverage(double avr){average = avr;}
void SetIsScore(bool b){isScore = b;}
int GetScore(int i){return score[i];}
bool GetIsInformation() {return isInformation;}
double GetAverage(){return average;}
bool GetIsScore(){return isScore;}
};
class ScoreManager{
Score *pSc[MAX_STD];
char *subject[MAX_SBJ];
int std_index;
int sbj_index;
public:
ScoreManager();
void ShowMenu();//¸Þ´º¼±ÅÃ
void CollegeGraduate();//Çлç
void ManagementConsult();//»ó´ã°ü¸®
void Mileage();//¸¶Àϸ®Áö
void DataManagement();//ÇÐÀûÀÚ·á°ü¸®
void EditPersonalInformation();//°³ÀÎÁ¤º¸¼öÁ¤
void Eclass();//Eclass
void StudentMainScreen();//Çлý¸ÞÀÎȸé
void CourseManagement();//¼ö°°ü¸®
void CourseSubjectView();//¼ö°°ú¸ñÁ¶È¸
void Grademanagement();//¼ºÀû°ü¸®
void CumulativeGradeReview();//´©Àû¼ºÀûÁ¶È¸
void ConsultationRequest();//»ó´ã½Åû
void PointAcquisition();//Æ÷ÀÎÆ® Ãëµæ ÇöȲ
void OutputScore();//¼ºÀûÁ¶È¸
void InputScore();//¼ºÀû ÀÔ·Â
};
PersonalInformation::PersonalInformation(int n, char *name)
{
num = n;
SetName(name);
}
void PersonalInformation::SetName(char *str)
{
name = new char[strlen(str)+1];
}
ScoreManager::ScoreManager()
{
std_index = 0;
}
void ScoreManager::OutputScore()
{
for(int i = 0; i < std_index; i++){
if(pSc[i] ->GetIsInformation()==true){
cout <<">Çйø : " << pSc[i]->GetNum() << endl;
cout <<">À̸§ : " << pSc[i]->GetName() << endl;
}
}
}
int main(void)
{
int menu;
ScoreManager sm;
while(1) {
sm.ShowMenu();
cout << "¸Þ´º¼±Åà : ";
cin >> menu;
switch(menu){
case 1 :
sm.CollegeGraduate();
int menu1 ;
while(1){
cout << "¸Þ´º¼±Åà : ";
cin >> menu1;
switch(menu1){
case 1 :
sm.DataManagement();
int menu2;
while(1){
cout << "¸Þ´º¼±Åà : ";
cin >> menu2;
switch(menu2){
case 1:
sm.EditPersonalInformation();
break;
case 2:
return 0;
default:
cout <<"À߸ø ÀÔ·Â Çϼ̽À´Ï´Ù." << endl;
}
break;
}
break;
case 2:
sm.Eclass();
int menu3;
while(1){
cout << "¸Þ´º¼±Åà : ";
cin >> menu3;
switch(menu3){
case 1:
sm.StudentMainScreen();
break;
case 2:
return 0;
default:
cout <<"À߸ø ÀÔ·Â Çϼ̽À´Ï´Ù." << endl;
}
break;
}
break;
case 3:
sm.CourseManagement();
int menu4;
while(1){
cout << "¸Þ´º¼±Åà : ";
cin >> menu4;
switch(menu4){
case 1:
sm.CourseSubjectView();
break;
case 2:
return 0;
default:
cout <<"À߸ø ÀÔ·Â Çϼ̽À´Ï´Ù." << endl;
}
break;
}
break;
case 4:
sm.Grademanagement();
int menu5;
while(1){
cout << "¸Þ´º¼±Åà : ";
cin >> menu5;
switch(menu5){
case 1:
sm.InputScore();
break;
case 2:
sm.CumulativeGradeReview();
break;
case 3:
return 0;
default:
cout <<"À߸ø ÀÔ·Â Çϼ̽À´Ï´Ù." << endl;
}
break;
}
break;
case 5:
return 0;
default:
cout <<"À߸ø ÀÔ·Â Çϼ̽À´Ï´Ù." << endl;
}
}
break;
case 2:
sm.ManagementConsult();
int menu6;
while(1){
cout << "¸Þ´º¼±Åà : ";
cin >> menu6;
switch(menu6){
case 1:
sm.ConsultationRequest();
break;
case 2:
return 0;
default:
cout <<"À߸ø ÀÔ·Â Çϼ̽À´Ï´Ù." << endl;
}
break;
}
break;
case 3:
sm.Mileage();
int menu7;
while(1){
cout << "¸Þ´º¼±Åà : ";
cin >> menu7;
switch(menu7){
case 1:
sm.PointAcquisition();
break;
case 2:
return 0;
default:
cout <<"À߸ø ÀÔ·Â Çϼ̽À´Ï´Ù." << endl;
}
break;
}
break;
case 4:
return 0;
default:
cout <<"À߸ø ÀÔ·Â Çϼ̽À´Ï´Ù." << endl;
}
break;
}
return 0;
}
void ScoreManager::ShowMenu(void)//¼±Åà ¸Þ´º ÇÁ¸°Æ®
{
cout << "========== ¸Þ ´º ==========" << endl;
cout << "1. ÇÐ »ç" << endl;
cout << "2. »ó´ã°ü¸®" << endl;
cout << "3. ¸¶Àϸ®Áö" << endl;
cout << "4. Á¾ ·á" << endl;
}
void ScoreManager::CollegeGraduate(void)//Çлç
{
cout << "========== ¸Þ ´º ==========" << endl;
cout << "1. ÇÐÀû°ü¸®" << endl;
cout << "2. E-Class" << endl;
cout << "3. ¼ö°°ü¸®" << endl;
cout << "4. ¼ºÀû°ü¸®" << endl;
cout << "5. Á¾ ·á" << endl;
}
void ScoreManager::DataManagement(void)//ÇÐÀû°ü¸®
{
cout << "========== ¸Þ ´º ==========" << endl;
cout << "1. °³ÀÎ Á¤º¸ ¼öÁ¤" << endl;
cout << "2. Á¾ ·á" << endl;
}
void ScoreManager::EditPersonalInformation(void)//°³ÀÎÁ¤º¸¼öÁ¤
{
int n;
char s[10];
cout << "-----°³ÀÎÁ¤º¸µî·Ï" << endl;
cout << "Çйø : " ; cin >> n;
cout << "À̸§ : " ; cin >> s;
pSc[std_index] = new Score(n,s);//Score °´Ã¼ µ¿Àû ¸Þ¸ð¸® ÇÒ´ç
std_index++;
for(int i = 0; i < std_index; i++){
if(pSc[i] ->GetNum() == n){
if(pSc[i]->GetIsInformation() == true){
cout <<"!!!ÀÌ¹Ì µî·ÏµÈ ÇлýÀÔ´Ï´Ù."<<endl;
return ;
}
pSc[i]->SetIsInformation(true);//Á¤º¸ ÀÔ·Â ¿©ºÎ Ç¥½Ã.
return;
}
}
}
void ScoreManager::Eclass(void)//Eclass
{
cout << "========== ¸Þ ´º ==========" << endl;
cout << "1. Çлý¸ÞÀÎȸé" << endl;
cout << "2. Á¾ ·á" << endl;
}
void ScoreManager::StudentMainScreen(void)//Çлý¸ÞÀÎȸé
{
char s;
ifstream fi;
fi.open("StudentMainScreen.txt");//ÀÔ·Â ÆÄÀÏ °³¹æ
if (!fi){
cout << "!Can't open input file <StudentMainScreen.txt>\n";
exit(1);
}
fi.unsetf(ios::skipws);
while (!fi.eof()){
fi >> s;
if (s==' ' )
s = ' ';//°ø¹éµµ Æ÷ÇÔÇØ¼ Ãâ·Â.
cout << s;
}
}
void ScoreManager::CourseManagement(void)//¼ö°°ü¸®
{
cout << "========== ¸Þ ´º ==========" << endl;
cout << "1. ¼ö°°ú¸ñÁ¶È¸" << endl;
cout << "2. Á¾ ·á" << endl;
}
void ScoreManager::CourseSubjectView(void)//¼ö°°ú¸ñÁ¶È¸
{
char s;
ifstream fi;
fi.open("CourseSubjectView.txt");//ÀÔ·Â ÆÄÀÏ °³¹æ
if (!fi){
cout << "!Can't open input file <CourseSubjectView.txt>\n";
exit(1);
}
fi.unsetf(ios::skipws);
while (!fi.eof()){
fi >> s;
if (s==' ' )
s = ' ';
cout << s;
}
}
void ScoreManager::Grademanagement(void)//¼ºÀû°ü¸®
{
cout << "========== ¸Þ ´º ==========" << endl;
cout << "1. ¼ºÀû ÀÔ·Â" << endl;
cout << "2. ´©Àû¼ºÀûÁ¶È¸" << endl;
cout << "3. Á¾ ·á" << endl;
}
void ScoreManager::CumulativeGradeReview(void)//¼ºÀû ÅëÁö¼
{
char s;
ifstream fi;
fi.open("CumulativeGradeReview.txt");//ÀÔ·Â ÆÄÀÏ °³¹æ
if (!fi){
cout << "!Can't open input file <CumulativeGradeReview.txt>\n";
exit(1);
}
fi.unsetf(ios::skipws);
while (!fi.eof()){
fi >> s;
if (s==' ' )
s = ' ';
cout << s;
}
}
void ScoreManager::InputScore()//¼ºÀûÀÔ·Â ¹× ±³°ú¸ñ µî·Ï ÀÛ¾÷Áß.......
{
int n, sc, total = 0;
char s[20];
cout <<"===±³°ú¸ñ µî·Ï===" << endl;
cout <<"°ú¸ñ ¼ö : " ; cin >>n;
for (int i = 0; i < n; i++){
cout <<"±³°ú¸ñ ¸í : " << i+1 << " : " ; cin >>s;
subject[i] = new char[strlen(s)+1];
}
sbj_index = n;
return;
cout <<"===¼ºÀûÀÔ·Â===" << endl;
cout <<"Çйø : " ; cin >> n;
for(int i = 0; i < std_index; i++){
if (pSc[i]->GetNum() == n){
if(pSc[i]->GetIsScore()==true){
cout << "!!! ÀÌ¹Ì ¼ºÀûÀÌ ÀԷµǾú½À´Ï´Ù.\n";
return;
}
cout <<"À̸§ : " <<pSc[i]->GetName() << endl;
for(int j=0; j < sbj_index; j++){
cout << "> " << subject[j] << " : ";
cin >>sc;
pSc[i]->SetScore(j,sc);
total += sc;
}
pSc[i]->SetAverage(total / double(sbj_index));
pSc[i]->SetIsInformation(true);
return;
}
}
}
void ScoreManager::ManagementConsult(void)//»ó´ã°ü¸®
{
cout << "========== ¸Þ ´º ==========" << endl;
cout << "1. »ó´ã½Åû" << endl;
cout << "2. Á¾ ·á" << endl;
}
void ScoreManager::ConsultationRequest(void)//»ó´ã½Åû
{
char s;
ifstream fi;
fi.open("ConsultationRequest.txt");//ÀÔ·Â ÆÄÀÏ °³¹æ
if(!fi){
cout <<"!Can't open input file <ConsultationRequest.txt>\n";
exit(1);
}
fi.unsetf(ios::skipws);
while(!fi.eof()){
fi >> s;
if( s ==' ')
s = ' ';
cout << s;
}
}
void ScoreManager::Mileage(void)//¸¶Àϸ®Áö
{
cout << "========== ¸Þ ´º ==========" << endl;
cout << "1. Æ÷ÀÎÆ® Ãëµæ ÇöȲ" << endl;
cout << "2. Á¾ ·á" << endl;
}
void ScoreManager::PointAcquisition(void)//Æ÷ÀÎÆ® ÃëµæÇöȲ
{
char s;
ifstream fi;
fi.open("PointAcquistion.txt");//ÀÔ·Â ÆÄÀÏ °³¹æ
if(!fi){
cout <<"!Can't open input file <PointAcquistion.txt>\n";
exit(1);
}
fi.unsetf(ios::skipws);
while(!fi.eof()){
fi >> s;
if( s ==' ')
s = ' ';
cout << s;
}
}
Á¦°¡ °ü¸® ÇÁ·Î±×·¥ ¸¸µé°í Àִµ¥,
switch - case¹®¿¡¼ Àú´Â Áߺ¹ ½ºÀ§Ä¡ ¹®À» »ç¿ëÇÏ¿´½À´Ï´Ù.
±Ã±ÝÇÑ °ÍÀº
¸Þ´º¸¦ ¼±ÅÃÇÏ¿© ÇÏÀ§ ¸Þ´º·Î µé¾î °¬À¸¸é, ´Ù½Ã »óÀ§¸Þ´º·Î °¡°í ½ÍÀºµ¥.. ¾î¶»°Ô ÇØ¾ß ÇÒÁö...
¸¸¾à Çлç-ÇÐÀû°ü¸®-°³ÀÎÁ¤º¸¼öÁ¤ ÀÌ·¸°Ô µé¾î °¡¼ µî·ÏÀ» ÇÑ ´ÙÀ½¿¡ ´Ù½Ã ¸Ç »óÀ§ ¸Þ´º·Î ´Ù½Ã µ¹¾Æ°¥ ¼ö ¾ø³ª¿ä??
|
Hit : 5515 Date : 2011/06/10 03:49
|