C++ 질문. 초보자

조회수 592회

이미지

//#include <iostream>
#include <string>
using namespace std;

class Employ {
    string name;
    string type;
public:
    Employ(string name, string type) {
        this->name = name; this->type = type;
    }
    string getName() { return name; }
    string getType() { return type; }
    void setType(string type) { this->type = type; }
    void setName(string name) { this->name = name; }
    virtual void show() = 0;
};
class FullTime : public Employ {
    int year;
    int off;
    double salary;
public:
    FullTime(string name, string type, double salary, int year) : Employ(name, type) {
        this->salary = salary; this->year = year;
    }
    void recruit();
    void promotion();
    double getSalary() { return salary; }
    void setSalry(double salary) { this->salary = salary; }
    void show();
};
class PartTime : public Employ {
    int basic;
    int time;
public:
    PartTime(string name, string type, int basic, int time) : Employ(name, type) {
        this->basic = basic; this->time = time;
    }
    int getMoney() { return basic * time; }
    void show();
};
class Manager : public FullTime {
public:
    Manager(string name, string type, double salary, int year) : FullTime(name, type, salary, year) { ; }
    void show();

};
class Assistant : public FullTime {
public:
    Assistant(string name, string type, double salary, int year) : FullTime(name, type, salary, year) { ; }
    void show();
};
class Worker : public FullTime {
public:
    Worker(string name, string type, double salary, int year) : FullTime(name, type, salary, year) { ; }
    void show();
};
class Menu {
    int id = 0;
public:
    Employ *e[100];
    void addemploy();
    void searchemploy();
    void listemploy();
    void run();
};
void PartTime::show() {
    cout << getName() << ": " << getType() << "," << getMoney() << endl;
}
void FullTime::show() {
    cout << getName() << ": " << getType() << "," << getSalary() << endl;
}
void FullTime::promotion() {
    if (year > 5) {
        if (getType() == "사원") {
            setType("대리");
            double salary = getSalary();
            salary = salary + salary * 0.1;
            setSalry(salary);
        }
        else if (getType() == "대리") {
            setType("과장");
            double salary = getSalary();
            salary = salary + salary * 0.1;
            setSalry(salary);
        }
    }
}
void FullTime::recruit() {

}
void Menu::addemploy() {
    string name, type;
    int year, basic, time, salary;
    cout << "직원 이름: ";
    getline(cin, name);
    cout << "직급: ";
    getline(cin, type);
    if (type == "시간제") {
        cout << "기본금: ";
        cin >> basic;
        cout << "근무시간: ";
        cin >> time;
        PartTime *p = new PartTime(name, type, basic, time);
        e[id] = p;
    }
    else {
        cout << "근무 연수: ";
        cin >> year;
        cout << "급여: ";
        cin >> salary;
        FullTime *f = new FullTime(name, type, salary, year);
        e[id] = f;
    }
}
void Menu::searchemploy() {
    string name;
    cout << "조회할 직원은 : ";
    getline(cin, name);
    bool exit = true;
    for (int i = 0; i <= id; i++) {

    }
}
void Menu::listemploy() {
    for (int i = 0; i <= id; i++) {
        e[i]->show();
    }
    cout << endl;
}
void Menu::run() {
    bool exit = true;
    while (exit) {
        char menu;
        cout << "메뉴선택(직원입력:A, 직원조회:S, 전체보기:L, 종료:Q)>> ";
        cin >> menu;
        switch (menu)
        {
        case 'A':
            addemploy();
            id += 1;
            cout << endl;
            break;
        case 'S':
            searchemploy();
            cout << endl;
            break;
        case 'L':
            listemploy();
            cout << endl;
            break;
        case 'Q':
            exit = false;
        default:
            break;
        }
    }
}
int main() {
    Menu *m = new Menu();
    m->run();

    delete m;
}

이거 중간에 작성하다가 한 번 돌려보려고 한거라서 보시기에 오류가 진짜 많을 거에요.. 실행 화면에서 저렇게 뜰 만한 요소가 있는지 한 번 만 봐주시면 감사하겠습니다ㅠㅠ

1 답변

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)