0 喜歡 0 不喜歡
738 瀏覽

Employee基礎類別,Employee包含getPay函數。請設計衍生類別Intern、PartTime跟FullTime,PartTime類別裡含有工作時數這個屬性,FullTime這類別裡含有月薪這個屬性,Intern不支薪,請再衍生類別裡實作基礎類別裡的函數。

Design a class Employee represent all kinds of employees. The Employee class should contain a member function getPay. The function getPay() will return an integer value as the payment

Design Intern class represent an intern that inherit Employee class and implement the member function in Employee class.

Design PartTime class represents a part-time that inherit Employee class and implement the member function in Employee class. This class includes attribute hours-of-duty.

Design Fulltime class represent full-time that inherit Employee class and implement the member function in Employee class. This class includes attribute monthly pay.

Remember that YOU CAN ONLY ADD YOUR CODE INSIDE THE SPECIFIC AREA

#include<iostream>

using namespace std;

class Employee
{
//your code here
};

class Intern : public Employee
{
//your code here
};

class PartTime : public Employee
{
//your code here
};

class FullTime : public Employee
{
//your code here
};

int main()
{
int money = 0;
PartTime user;
FullTime user2;
Intern user3;

money = user.getPay();
cout<<"Partime : " << money<<endl;
money = user2.getPay();
cout<<"Full time monthly pay : " << money<<endl;
money = user3.getPay();
cout<<"Intern : " << money<<endl;
return 0;
}

Expected output:

Partime : 120 
Full time monthly pay : 50000 
Intern : 0

[練習] Coding (C) - 最新提問 分類:C++ |
ID: 24828 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 738 瀏覽
0 0
Called for Help
0 0
Called for Help

18 個回答

0 喜歡 0 不喜歡
內容已隱藏
* ** *** ****



using *** std;



class * **

{

//your code here
****** ***
* ****** * * * ** ** ***** ***
* **** *** **** ** *** ** * ** ** ** *** *** = 120;
** *** * * *** * * **
* * * *** * ** * ** * *** **
***** * ** *** * ** ** salary;

};



class Intern : public Employee

{

//your code here
***** ** *
*** *** *** * * * *
*** ***** ** ** * *** * * * ***** * **** * = 0;
* ** ** **** * ** *
** **** ** ** ** ** ** * * * **

};



class PartTime : public Employee

{

//your code here
* ** * * ** * *
** * ** **** * ** ***** ***
* ** * **** * ** * * ** ** * ** * * **** * ** * * = 1;
* * * *** ** * * **** **** * **** ** * * = 120;
** ****** ** * * ** * ** * *
*** *** * ** *** * * *
*** * * * * *
*** * ** * *** * * * ** *

};



class FullTime : public *****

{

//your code here
** ** * * ***
** ** ** *** * * ***** ** *** * ** {
**** * * * *** * ** **** ** * = 50000;
* ** ** * *** ** * *** * *
* * * * ** * *** *
* *** * * ** ** *
** * *** ***** ** ** *** ** **

};



int main()

{

int money = 0;
** user;
* * * user2;

Intern user3;



money = * *****
**** *** * * ** * ** : * * * * * * ** ** *****

money = * **
* * * * ** * * ** time monthly pay : **** * ** ** * * * *** * ** ******

money = ***** *
*** ** * * **** * ** * : * * * * * ** * * ** ** **

return 0;

}



int * *** *
**** ** **** ** ***** * * ** salary;

}



int ** * * *
* * * * * ** * ** ******* salary;

}



int ** ***** * *
* ** *** * * ** * * ** * **

}



int **
* * * * * * * *** * * ** * * ****

}
最新回答 用戶: (237 分)
0 喜歡 0 不喜歡
內容已隱藏
** **** *** * * * * ****



using * * std;



class ***

{

//your code here
** * * *
** **** * ***** * * ** * *
** *** * *** ** * ** * * ** * *** ** = 120;
* * * *** ** ** * ** * *
* * ** * ** *** ** * *** * ***
* **** * ** * salary;

};



class Intern : public Employee

{

//your code here
* ** * * *
* **** * *** ** * ** * * * *
* ** ** *** * ** *** * * * * * **** * ** * ** = 0;
*** * ***** ** ** **** **
****** * * ** * ** *

};



class PartTime : public Employee

{

//your code here
*** ** * ** * *
* * *** **** **** ** *
* * ** * * * * ** ** * * ****** **** ** * *** = 1;
* ** * * ******** ****** * * * ** ******** = 120;
* * ** ** * ****** *
** * * ** * ** * * *** **
***** ****** * **
* *** * * ***** * ** **

};



class FullTime : public ** **

{

//your code here
* *** *** *****
* * ** * * * * * * * ** * {
* ** ** ** ** *** * * **** *** ** ** ******** ** * = 50000;
** ** *** * *
***** * *** *** * *
** *** * * * *
** * **** *** *** * *

};



int main()

{

int money = 0;
** user;
**** ** user2;

Intern user3;



money = * ** **
*** ** * **** * ** * : ** ** * * * * * * * * * ** **

money = ***** *
** *** * * time monthly pay : ** * * * *** * *** **** * ** * *

money = ** * **
** * *** *** *** ** : * * ** * ** ** ** *** ** ***

return 0;

}



int * * ** *
****** * * *** * *** ** * salary;

}



int * ** ** *
** * **** ** ** ** * * salary;

}



int * ** ***
****** * ** * ******** *** ** ** *

}



int * ****
* * ** *** *** *** * * * ** ***

}
最新回答 用戶: (126 分)
0 喜歡 0 不喜歡
內容已隱藏
** ****** ** **


* ** * std;


** * *

{
* * code here
******* *
** *** **** ** * * ** *****


** *
***** ** * *** ** ** * * **** * ** * * *

};


*** * * : * ** *

{
* code here
* *
* ****** * ***** **** ** = 0;}



};


* ** * : * * * *** *

{
** code here
**
***** ** ** *** * **** ** **** = **

};


** : * *

{
* * * code here
** ***
* ***** ** * *** ** *** * * ** * = ** *

};



int *

{

int money = 0;
**** * user;
**
** ** * *


** = ** * **
* ** *** *** * ** *** : * * * * * * *** *** *** *
** = ** ** * *
* * * *** * ** **** * time * pay : * ** **** ** * * * *** *** **
* ** = *** **
** * * *** ** ** ** ** : * ** ** ** ** ** *** * * * *
* ** 0;

}
最新回答 用戶: (-298 分)
0 喜歡 0 不喜歡
內容已隱藏
** * * ****


** * std;


* * ** *

{
* * code here
**** **
* ** * ** *** * * * *


* *
* *** * *** * **** * * * **** * **

};


* *** : * * * * *

{
* **** code here
***
* * * * ** * *** * * ** = 0;}



};


*** * ** * : *** *

{
* ** code here
* *
***** * ** **** ** ** * * * * = **

};


* *** : ** * *

{
*** * code here
****
** * * * * ** * * *** * = * * *

};



int ***

{

int money = 0;
* user;
****** * *
***** ***


* ** = ** ***
***** ** ** * ** ** * *** : * * *** ** * * ** * **
* = ** * * **
** * ** *** ***** time ** pay : **** * *** * * * * * * ** **
* * = * * ** **
* * ** * * * * **** : *** **** * * ** ** * *** * *** *
* 0;

}
最新回答 用戶: (-215 分)
0 喜歡 0 不喜歡
內容已隱藏
* * **** **


* * ** std;


* *

{
* * code here
* * * *
****** ***** *** * *** * * **


* **
** * ** *** ** ** * * * * ** *

};


* * *** : ***

{
* code here

* * *** ** * **** ** * ***** * = 0;}



};


* * : * ** *****

{
*** code here
*
* *** * ** ** * ***** * ** * ** = *

};


* * *** * : ** ****

{
** * code here
* *
* *** * **** * **** * ****** = ****

};



int *

{

int money = 0;
* *** user;
**
** ** *


*** * = * * *
******** ** * **** * : * * *** ** * *** ** *** *
** = ** ** *
* * * **** * * time * pay : ** ** *** * ** * * ** * ***** **
* = **** *****
** ** * * * * ** *** : * * * *** ** * * * **** ** ** *
* 0;

}
最新回答 用戶: (-215 分)
0 喜歡 0 不喜歡
內容已隱藏
* *** * * * *


* *** * * std;


* * *

{
* ** code here
* *
*** *** ** * ****** ** ** *** *


*** *
* * **** **** * * *** ***** ** * * * *

};


* * ** : **** * ** ***

{
* * code here
** * *
* * *** **** ** ** ** = 0;}



};


** ** ** : * * ** * *

{
* code here
* *
** * * ** ** **** * ****** **** = * *

};


** *** * : *

{
*** code here
*** *
* ** ** *** * * ** * * * * = * *

};



int *

{

int money = 0;
* * * user;
** ***
* *


= ** *** *
** **** *** * ** *** : ** **** *** ** * * * *
** = * *** *
* * **** * **** * ** time ****** pay : *** * ** * * ** * * ** **
*** = ** *
** *** ******** *** : ** * ***** * * ** * **** **
0;

}
最新回答 用戶: (126 分)
0 喜歡 0 不喜歡
內容已隱藏
* ** * ** ****


* * * * std;


* * * ** *

{
** code here
*
** * ** ** * * * *** *


**
* * * *** * * ** ** * * * * **

};


* ** ** : * * *

{
** code here
* *
** ******** **** * ** * * * = 0;}



};


** **** : ** *** *

{
* code here
***
**** * * ** *** * ** * *** *** ** =

};


* ** ***** : ** * ** *

{
* * code here
** *
**** *** * ** ** *** * ** * = ***

};



int *

{

int money = 0;
**** user;
* *
** *


* = **** * *
* * * ** ** *** * * ** : ** ** ****** * * * * ***
* * = *** *** ***
* * * ** * *** *** * time ** pay : * *** * ***** * * * *
* = * ***
** ***** *** ** **** : ** ** ***** ** * * ** **
* 0;

}
最新回答 用戶: (126 分)
0 喜歡 0 不喜歡
內容已隱藏
*** *** **** * **



using namespace std;



class Employee

{
* * ******* ** * *
** **** * ** * * ** * * ** * *** ** * *** * int getPay(){
*** ** * **** **** * *** * * ** * ** ** **** ******* * * * * S;
* ** *** *** * * * *** ***** * ***
***** * * * * * ***** *** *
*** * * * * ** * *** * ** * ** * * ** * S;

};



class Intern : public Employee

{
** ** ** * * ** * ********
****** * * ** *** ***** * ** * **** ** * **** *** **
** ** ** ** *** ** * * *** * ** * * ** * * * ** *** * * * * * * = 0;
* **** ** ***** **** *** * * * **



};



class PartTime : public Employee

{
* *** * * ** ** ** * *
** * * * * **** * * ** * * ** ** ** ** ** * *
* ** **** * **** * * ***** * ** ****** * * * *** * *** *** ** = 120;
** * * ** ** * * * ** ** * * *** *********

};



class FullTime : public Employee

{
** * * * ** * * *** * * **** **
** * * * * * ** ***** ** * *** ** ****** ** ** * {
* * ***** *** * * ** * * * ** ** **** **** * * ** * ** **** * * ** ** = 50000;
** * * * **** * * ***** ** *** * *** **** ** *

};



int main()

{
* * ** * ** * ** money = 0;
* ** * ** * ** ** user;
** ** * ** * **** * *** * user2;
** * * *** * ** ** * **** * ** user3;


* ** ** * * ** ** * * * ** = user.getPay();
* * * * * * *** * * * ** ** : " << money<<endl;
** ** * * *** ** = user2.getPay();
* * * * *** * * *** * * * time monthly pay : " << ***** *** *
*** **** **** *** ** = user3.getPay();
* * ** * ** * * * ** * * * * **** * : " << money<<endl;
*** * ** * * * *** * ** ** 0;

}
最新回答 用戶: (-249 分)
0 喜歡 0 不喜歡
內容已隱藏
* ** **** ****

using namespace std;



class Employee

{
** ** ** * *** *** *
*** * * ** * * * ** **** payT){
****** *** ****** * * ** *** ***** * *** * = payT;
* * ** *** * ***** * *
* ****** ** * * ** getPay(){
* * ** ***** * **** * ** * *** * * * * **** * * *** pay;
** ** * *** * * * *****
* * ** ** ** *****
**** *** ** *** * * **** pay;

};



class Intern : public Employee

{
* *** * ** ** ** **
* ******** **** *** ** * *** ** * * **** * ** * * ** * *
* * *** * ** * * * ** * ***** * ** getPay(){
** * * * * *** ** * * **** ** ***** ** * ****** *** *** *** * *** 0;
* * *** * * ** * * * **** * ** * * * *
* **** * * * * **** ** * **** ***** **
** ** **** * * *** ***
* * ** * * **** * ** ** * ** * * ** *** pay;

};



class PartTime : public Employee

{
**** * ** * ** ***
* ** * * * ** ** * ** * ** ** **** ** * **** * ***
* * * ** * * * * * *** ** **** * * * **** getPay(){
*** * ****** ** **** ** *** * ** *** * **** ***** *** ***** *** * 120;
* **** *** *** * * * * ** * ** * ** ** *****
** * *** * ***** * * * ** * * **
** * * * * **** ********** **** * **
** **** * * * * * * * * **** **** * * **** **** *** *** *** *** * pay;

};



class FullTime : public Employee

{
* * *** * * ** *** ****
* **** ** ** ** *** *** * * * ** * ** ***** * ***
* * * * * **** ** ****** ******* **** getPay(){
**** *** ** * ** * * ** **** ** * * * * * * ** **** * * 50000;
* * ** * **** ** *** * *** **
* * ***** * ** * ** * ** * ***** * * *
* * ** * * * * ** * * * * * ** * *****
* * ** **** *** * * * * ** *** ** ** * * * ******* *** *** ** pay;

};



int main()

{

int money = 0;

PartTime user;

FullTime user2;

Intern user3;



money = user.getPay();
** ** * **** *** * * * : " << money<<endl;

money = user2.getPay();
** * *** ** ** ** time monthly pay : " << money<<endl;

money = user3.getPay();
* ** ** * * ** * : " << money<<endl;

return 0;

}
最新回答 用戶: (-136 分)
0 喜歡 0 不喜歡
內容已隱藏
**** * * *********


* * **** std;


* * ***

{
* * code here
* ***
**** * * * * * * * *


***
** ** * ********* * * * * ****

};


* ** * * : ** ***

{
** * code here
*
*** * ** ** **** * ** * * *** ** = 0;}



};


** * * : * * ** *

{
* * code here
***
*** * * * *** *** * * = ****

};


* **** : ** * *

{
*** code here
**
*** **** * *** * ****** ** *** * * * = *****

};



int *

{

int money = 0;
** * user;
*** *
* * **


** = ** ***
* ** ** ** * *** : * * * ** * **** **** * * * **
** = ****** *
*** ** * ** * ****** *** time * pay : * * * ** **** ***** *** **
*** = ****** **
* * * ** * * : * ** ** * ****** * ****
* *** 0;

}
最新回答 用戶: (-189 分)
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.69.6.253
©2016-2024

相關問題

0 喜歡 0 不喜歡
15 回答
[練習] Coding (C) - 最新提問 6月 1, 2017 分類:C++ |
ID: 24854 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 577 瀏覽
0 喜歡 0 不喜歡
17 回答
[練習] Coding (C) - 最新提問 6月 1, 2017 分類:C++ |
ID: 24855 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 646 瀏覽
0 喜歡 0 不喜歡
23 回答
[練習] Coding (C) - 最新提問 5月 11, 2017 分類:C++ |
ID: 24589 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 871 瀏覽
0 喜歡 0 不喜歡
31 回答
[練習] Coding (C) - 最新提問 5月 11, 2017 分類:C++ |
ID: 24588 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 975 瀏覽
12,783 問題
183,443 回答
172,219 留言
4,824 用戶