Advertisement
jordanov

Untitled

Mar 7th, 2016
334
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4.  
  5. class Direktor{
  6. private:
  7. char ime;
  8. char prezime;
  9. float plata;
  10. int brOddeli;
  11. bool bonus;
  12.  
  13. public:
  14. //default konstruktor - bez argumenti
  15. Direktor(){
  16.  
  17. }
  18.  
  19. //konstruktor so argumenti
  20. Direktor(char ime,char prezime,float plata,int brOddeli,bool bonus){
  21. ime = new char[strlen(ime)+1];
  22. strcpy(this->ime,ime);
  23.  
  24. prezime=new char[strlen(prezime)+1];
  25. strcpy(this->prezime,prezime);
  26.  
  27.  
  28. this->plata=plata;
  29. this->brOddeli=brOddeli;
  30. this->bonus=bonus;
  31. }
  32.  
  33. /*Direktor(float plata,int brOddeli,bool bonus){
  34. this->ime="";
  35. this->prezime="";
  36. this->plata=plata;
  37. this->brOddeli=brOddeli;
  38. this->bonus=bonus;
  39.  
  40.  
  41. }*/
  42. char get_ime()
  43. {
  44. return ime;
  45. }
  46.  
  47. char set_ime(char ime)
  48. {
  49. ime = ime;
  50. }
  51.  
  52. char get_prezime()
  53. {
  54. return prezime;
  55. }
  56.  
  57. char set_prezime(char prezime)
  58. {
  59. prezime = prezime;
  60. }
  61.  
  62. float set_plata(float plata)
  63. {
  64. plata = plata;
  65. }
  66.  
  67. float get_plata()
  68. {
  69. return plata;
  70. }
  71.  
  72. void set_brOddeli(int brOddeli)
  73. {
  74. brOddeli=brOddeli;
  75. }
  76.  
  77. int get_brOddeli()
  78. {
  79. return brOddeli;
  80. }
  81.  
  82. void set_bonus(bool bonus)
  83. {
  84. bonus = bonus;
  85. }
  86.  
  87. bool get_bonus()
  88. {
  89. return bonus;
  90. }
  91.  
  92. //copy konstruktor
  93. Direktor(const Direktor &d){
  94. ime = new char[strlen(d.ime)+1];
  95. strcpy(this->ime,d.ime);
  96.  
  97. prezime=new char[strlen(d.prezime)+1];
  98. strcpy(this->prezime,d.prezime);
  99.  
  100.  
  101. this->plata=d.plata;
  102. this->brOddeli=d.brOddeli;
  103. this->bonus=d.bonus;
  104. }
  105.  
  106. int presmetaj(){
  107. int result = 0;
  108.  
  109. result=plata+10*brOddeli;
  110. if(bonus)==true){
  111. result+=1000;
  112. }
  113.  
  114. return result;
  115. }
  116.  
  117. void pecati(){
  118. cout << presmetaj(); << endl;
  119. }
  120. };
  121.  
  122.  
  123.  
  124. int main()
  125. {
  126. Direktor d;
  127.  
  128. cin>>d.ime>>d.prezime>>d.plata<<d.brOddeli<<d.bonus;
  129.  
  130. d.pecati();
  131.  
  132.  
  133. // cout << "Hello world!" << endl;
  134. return 0;
  135. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement