0 thích 0 k thích
647 đã xem

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

[Exercise] Coding (C) - đã hỏi trong C++
ID: 24828 - Xem được từ: Không giới hạn - Hiệu lực đến: Không giới hạn
| 647 đã xem
0 0
Called for Help
0 0
Called for Help

18 Trả lời

0 thích 0 k thích
Hidden content!
* * * ** ***



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 * * * **
* * * * * * * *** * **** *

}
trả lời bởi (237 điểm)
0 thích 0 k thích
Hidden content!
* ******* **********



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 ******
**** ****** * ** * * * * **** ***

}
trả lời bởi (126 điểm)
0 thích 0 k thích
Hidden content!
* * * *** *


* ** * ** std;


* * * ***

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


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

};


*** *** : * ** *

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



};


* * * : * * ***

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

};


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

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

};



int

{

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


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

}
trả lời bởi (-298 điểm)
0 thích 0 k thích
Hidden content!
* *** * * *****


** * * std;


****

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


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

};


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

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



};


* * * : * * *

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

};


* ** * : *** ** *

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

};



int * *

{

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


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

}
trả lời bởi (-215 điểm)
0 thích 0 k thích
Hidden content!
* *** ****** **


* * std;


***** *** **

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


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

};


* * : ** * *

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



};


* * * : * **

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

};


** * * *** : ** *

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

};



int * *

{

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


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

}
trả lời bởi (-215 điểm)
0 thích 0 k thích
Hidden content!
* *** * * * ****


* * std;


***** ** *

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


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

};


* * : * *

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



};


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

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

};


* * ** * : * * * * *

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

};



int * *

{

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


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

}
trả lời bởi (126 điểm)
0 thích 0 k thích
Hidden content!
* ** ****** * * **


** * std;


* *

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


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

};


* *** : * * *

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



};


* * *** : * ** **

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

};


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

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

};



int *

{

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


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

}
trả lời bởi (126 điểm)
0 thích 0 k thích
Hidden content!
*** **** * ** *



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;

}
trả lời bởi (-249 điểm)
0 thích 0 k thích
Hidden content!
* *** *** ** **** *

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;

}
trả lời bởi (-136 điểm)
0 thích 0 k thích
Hidden content!
**** ** * *****


**** ***** std;


***** * **

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


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

};


* : ** * *

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



};


*** * * ** : ***

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

};


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

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

};



int

{

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


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

}
trả lời bởi (-189 điểm)
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.69.58.174
©2016-2024

Những câu hỏi liên quan

0 thích 0 k thích
15 trả lời
[Exercise] Coding (C) - đã hỏi ngày 1 tháng 6 năm 2017 trong C++
ID: 24854 - Xem được từ: Không giới hạn - Hiệu lực đến: Không giới hạn
| 503 đã xem
0 thích 0 k thích
17 trả lời
[Exercise] Coding (C) - đã hỏi ngày 1 tháng 6 năm 2017 trong C++
ID: 24855 - Xem được từ: Không giới hạn - Hiệu lực đến: Không giới hạn
| 576 đã xem
0 thích 0 k thích
23 trả lời
[Exercise] Coding (C) - đã hỏi ngày 11 tháng 5 năm 2017 trong C++
ID: 24589 - Xem được từ: Không giới hạn - Hiệu lực đến: Không giới hạn
| 765 đã xem
0 thích 0 k thích
31 trả lời
[Exercise] Coding (C) - đã hỏi ngày 11 tháng 5 năm 2017 trong C++
ID: 24588 - Xem được từ: Không giới hạn - Hiệu lực đến: Không giới hạn
| 829 đã xem
12,783 câu hỏi
183,443 trả lời
172,219 bình luận
4,824 thành viên