Advertisement
Guest User

Untitled

a guest
Jun 24th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. class KartaPlatnicza{
  7. private:
  8. string numer_karty;
  9. string nazwa;
  10. int miesiac;
  11. int rok;
  12.  
  13. public:
  14. KartaPlatnicza(){
  15. numer_karty = "0000 0000 0000 0000";
  16. nazwa = "brak";
  17. miesiac = 1;
  18. rok = 2018;
  19. }
  20. KartaPlatnicza(string number_card, string name, int month, int year) :numer_karty(number_card), nazwa(name), miesiac(month),rok(year)
  21. {
  22. }
  23.  
  24. string Getnumer_karty() {
  25. return numer_karty;
  26. }
  27.  
  28. void Setnumer_karty( string number_card) {
  29. numer_karty = number_card;
  30. }
  31.  
  32. string Getnazwa() {
  33. return nazwa;
  34. }
  35.  
  36. void Setnazwa(string name) {
  37. nazwa = name;
  38. }
  39.  
  40. int Getmiesiac() {
  41. return miesiac;
  42. }
  43.  
  44. void Setmiesiac(int month) {
  45. miesiac = month;
  46. }
  47.  
  48. int Getrok() {
  49. return rok;
  50. }
  51.  
  52. void Setrok(int year) {
  53. rok = year;
  54. }
  55.  
  56. string virtual DaneKarty() {
  57. return "";
  58. }
  59.  
  60. };
  61.  
  62.  
  63.  
  64. class KartaKredytowa:public KartaPlatnicza{
  65. private:
  66. int limit_kredytu;
  67. int wydatki_biezace;
  68.  
  69. public:
  70.  
  71. KartaKredytowa(string noc, string n, int m, int y, int l):KartaPlatnicza(noc,n,m,y) {
  72. limit_kredytu = 0;
  73. wydatki_biezace = 0;
  74.  
  75.  
  76. }
  77.  
  78. string DaneKarty() {
  79. return Getnumer_karty() + " " + Getnazwa() + " " + to_string(Getmiesiac()) + " " + to_string(Getrok())+" ";
  80. };
  81.  
  82. bool Transakcja(int wartosc_rzeczywista) {
  83.  
  84. if (wydatki_biezace + wartosc_rzeczywista <= limit_kredytu) {
  85. wydatki_biezace = wydatki_biezace + wartosc_rzeczywista;
  86. return true;
  87. }
  88. else
  89. return false;
  90.  
  91. }
  92.  
  93. void Splata(double wysokosc_splaty){
  94. wydatki_biezace = wydatki_biezace - wysokosc_splaty;
  95.  
  96. }
  97. };
  98.  
  99.  
  100.  
  101.  
  102. int main() {
  103.  
  104. KartaPlatnicza *wsk1 = new KartaKredytowa("1234 4567 7890 0123", "lucas", 11, 2020,3433);
  105. KartaPlatnicza *wsk2 = new KartaKredytowa("1233 3424 3242 3242", "alior", 1, 2010,3433);
  106. KartaPlatnicza *wsk3 = new KartaKredytowa("3242 3423 6767 5654", "lucas", 9, 2018,3434);
  107.  
  108. wsk1->Setnazwa("lucasnwe");
  109. wsk2->Setmiesiac(2);
  110. wsk3->Setnumer_karty("3004 4335 3242 9099");
  111.  
  112. cout << wsk1->DaneKarty();
  113.  
  114. cout << static_cast<KartaKredytowa*>(wsk1)->Transakcja(10) << endl;
  115. cout << static_cast<KartaKredytowa*>(wsk1)->Transakcja(100) << endl;
  116. static_cast<KartaKredytowa*>(wsk1)->Splata(40);
  117. static_cast<KartaKredytowa*>(wsk1)->Splata(80);
  118. cout << static_cast<KartaKredytowa*>(wsk1)->Transakcja(30) << endl;
  119.  
  120. delete wsk1;
  121. delete wsk2;
  122. delete wsk3;
  123.  
  124. system("pause");
  125. return 0;
  126. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement