0 like 0 dislike
675 views

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) - asked in C++
ID: 24828 - Available when: Unlimited - Due to: Unlimited
| 675 views
0 0
Called for Help
0 0
Called for Help

18 Answers

0 like 0 dislike
Hidden content!
* ** ****** * * *



using * * **** std;



class * **

{

//your code here

* *** ** * **** ** *** * * *
** *** *** * ***
* * * ** ** * ***** * **** ** * ** * *** * * money;
** * **** * * * ** **
* **
* * * *** ******* **** money;

};



class Intern : public *

{

//your code here
*** * *
***** *** **** **** ***********
** * * **** ** * *** ** **
**** ** ********* ** * *
****** * ** ** * *** ***** ** ** * * * *** ** money1;
** *** ** *******
* ***
* *** * ***** ** * ** * * * ** * money1;

};



class * * : public * * *

{

//your code here
***
** * * *** * * * * *** * **
* * ** * * * * **** *
** ** * * * ** *
* **** ***** ** * * * * * * * * * ** ***** money2;
********** ******* ***
* ** * *
* ** ** **** * * ******* money2;

};



class ** * : public * *

{

//your code here
***
** * *** ** ****** * ** ***** ***
* * *** **** *
* * * *** * **** * * *
** *** ** * * * ** * * *** * * * *** money3;
***** ** * ** ** **** * * * *
*** * **
***** ** ** * ** ** * money3;

};



int main()

{

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

Intern user3;



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

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

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

return 0;

}
answered by (-412 points)
0 like 0 dislike
Hidden content!
** * ***** *



using * ** std;



class Employee

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

};



class Intern : public Employee

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

};



class ** ** : public Employee

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

};



class FullTime : public Employee

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

};



int main()

{

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

Intern user3;



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

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

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

return 0;

}
answered by (-364 points)
0 like 0 dislike
Hidden content!
** ** * ** * * ** *



using *** std;



class *** *

{
* code here
*** *
* * * * * ** * * ** *
* * * ** *** * *** * * ** ** *** ** **
* **** ** * **** *
** * ** ** **** ** * * * *** * *
*** *** * *** * ** ** * * ** **** * * * **** Money;
**** * * * * *** * *
*** * ** * ** * ** *** Money;

};



class Intern : public ** **

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

};



class * ** * : public **

{

//your code here
** *
** ****** *** ** *** * * * *
** ** **** * * * * * ** * **
* ** * * *** ** ** **

};



class ****** : public **

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

};



int main()

{

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

Intern user3;



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

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

money = ** * * * *
* * ** * **** * ********* : ** * *** *** * * * * * *
** 0;

}
answered by (-581 points)
0 like 0 dislike
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;

}
answered by (-384 points)
0 like 0 dislike
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 * * **** **
** * **** **** * ** ** ***

}
answered by (5.2k points)
0 like 0 dislike
Hidden content!
* ** ** *** *** ***

using ** std;



class * **

{
**** * * **
* * ** * * *** ** payT){
*** *** * *** *** * *** * pay = payT;
* ** *** * ** }
* **** * * * int * ***
** *** * * * * ** * return pay;
*** * * * * ** }
* ** * * * * * * *
* * * *** int pay;

};



class Intern : public ** *

{
* *** * * * *
* ***** ** *** *** * ******* * *
*** * ** ** * * *** int *** *
*** **** ** * * * * ** * **** **** return 0;
* ** ** * * ** * ** }
*** * * ** ** * *

**** * ** * ******
*** * * *** * * * * * *** int pay;

};



class * : public * ** * *

{
*** * **** * * *
* * * *** ** * * * ** **** *
* ** * * * ** int ****
* ** * *** * ** ** * *** *** ** return 120;
* **** ** ** * * * * }
*** * * ** ** * ** **** ****

***** *** * * * * *
*** * **** **** ** * * **** *** *** int pay;

};



class *** ** : public **

{
* ** * * * *
**** * * ** * ** * ** * **** *
* * * * * * * int ** *
* * * * ** * * * ** * * ** * * ** *
* ** **** * * * * ** }
* ** ** * * *

*** * ** * *** ** * *
* *** * * * * * ***** * * *** * int pay;

};



int *

{

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


** = * *
** ** * ** * *** : * * * * ** * ** ** *** * ***
***** = ** *
** ****** *** ***** time ** pay : * ** * *** * * * *** * * **

money = * * * *
* * * *** * : *** * ** * **** * * *** *
* * 0;

}
answered by (-134 points)
0 like 0 dislike
Hidden content!
* * * ** *** **



using * ** std;



class *

{
* * code here
* *
******* ** ** ** ** * * Pay;
* *
*** * * * * * ** * ** *** * *
* *** ** ******* * * **** **** *** Pay;
* ** *** * * * ******

};



class Intern : public * ** *

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

};



class ** : public ***

{
* * code here
* *
*** ** * * ** * ** * ** *
*** * * * * * * * * * * * ****** * * = 120;
**** * ** ** ** * * * **

};



class * * * : * * *** *

{
* *** code here
*
*** * * ** ** ***** ***** **
* *** * * * * * * * * * * * ***** = 50000;
* * * * * * ****

};



int main()

{

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


** = * ** * **
* ** * ***** : * ** ** * *** ** ** ** * * *** **** *

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

money ** * * *
* ** * **** * * : **** *** * *** * ** * * * *
* 0;

}
answered by (-368 points)
0 like 0 dislike
Hidden content!
#include ***** *** **

using namespace std;





class Employee

{
***** ** **** * ** ** ****
* ** * * * * ******* * ** ** *** * *** ** * pay;
* * ***** * * * ** *
** * ******* * * ** **** ** *** ***** ** * ** *
* * * *** **** *** ****** *** ** * * ** * * ** setpay(int x);
* * ** *** * * ** * ******* * **** *********** **** **** * * * *



};
*** * * *

{
** *** * ** ** * *

}

void **** * ** x)

{
** ***** * * **** * * * * **

}

int * ** **

{
***** * *** * * ** ** ** pay;

}



class Intern : public Employee

{
** * * **** * * *
* *** ** *** * * ** ** * **** * ** * * **

};
* *

{
** *** **** ** *** * * ***
* ** *** * ** *** ** ** * * * *

}



class PartTime : public Employee

{
** ** ********** * * ** *
**** * *** ** * ** ** * *** * **** **** * *** **

};
* * * **

{
* *** ** * * * *** * *
* ****** * ** * * * * *
***** ** * ****** * ** * *

}



class FullTime : public Employee

{
* ** * * *** ** ** *** ***
** * * ***** *** ** ***** * * * ** * * *** * * **
* * * *** * ***** ******* * * * ****** *** ****


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

};





int main()

{

int money = 0;

PartTime user;

FullTime user2;

Intern user3;



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

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

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

return 0;

}
answered by (0 points)
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.69.58.122
©2016-2024

Related questions

0 like 0 dislike
15 answers
[Exercise] Coding (C) - asked Jun 1, 2017 in C++
ID: 24854 - Available when: Unlimited - Due to: Unlimited
| 531 views
0 like 0 dislike
17 answers
[Exercise] Coding (C) - asked Jun 1, 2017 in C++
ID: 24855 - Available when: Unlimited - Due to: Unlimited
| 617 views
0 like 0 dislike
23 answers
[Exercise] Coding (C) - asked May 11, 2017 in C++
ID: 24589 - Available when: Unlimited - Due to: Unlimited
| 805 views
0 like 0 dislike
31 answers
[Exercise] Coding (C) - asked May 11, 2017 in C++
ID: 24588 - Available when: Unlimited - Due to: Unlimited
| 886 views
12,783 questions
183,443 answers
172,219 comments
4,824 users