Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.12 KB | None | 0 0
  1. // Łukasz.cpp : main project file.
  2.  
  3. #include "stdafx.h"
  4.  
  5. #include <iostream>
  6. #include <string>
  7.  
  8.  
  9. using namespace std;
  10.  
  11. class KartaPlatnicza {
  12.  
  13. private:
  14.     string numer_karty;
  15.     string nazwa;
  16.     int miesiac;
  17.     int rok;
  18.  
  19.  
  20. public:
  21.     KartaPlatnicza() {
  22.         numer_karty = "0000 0000 0000 0000";
  23.         nazwa = "brak";
  24.         miesiac = 1;
  25.         rok = 2018;
  26.     }
  27.  
  28.  
  29.     KartaPlatnicza(string numer, string n, int msc, int r) : numer_karty(numer), nazwa(n), miesiac(msc), rok(r)
  30.     {
  31.     }
  32.  
  33.     string Getnumer_karty() {
  34.         return numer_karty;
  35.  
  36.     }
  37.  
  38.     void Setnumer_karty(string numer) {
  39.  
  40.         numer_karty = numer;
  41.  
  42.     }
  43.  
  44.  
  45.     string Getnazwa() {
  46.         return nazwa;
  47.  
  48.     }
  49.  
  50.     void Setnazwa(string name) {
  51.  
  52.         nazwa = name;
  53.  
  54.     }
  55.  
  56.  
  57.     int Getmiesiac() {
  58.         return miesiac;
  59.     }
  60.  
  61.     void Setmiesiac(int month) {
  62.  
  63.         miesiac = month;
  64.  
  65.     }
  66.  
  67.     int Getrok() {
  68.         return rok;
  69.  
  70.     }
  71.  
  72.     void Setrok(int year) {
  73.  
  74.         rok = year;
  75.  
  76.     }
  77.  
  78.  
  79.     string virtual DaneKarty() {};
  80.  
  81.  
  82. };
  83.  
  84.  
  85.  
  86. class KartaKredytowa :public KartaPlatnicza {
  87. private:
  88.     int  limit_kredytu;
  89.     int wydatki_biezace;
  90. public:
  91.  
  92.     KartaKredytowa(string nk, string naz, int m, int ro, int limit) :KartaPlatnicza(nk, naz, m, ro) {
  93.         wydatki_biezace = 0;
  94.     }
  95.  
  96.     string DaneKarty() {
  97.  
  98.         return Getnazwa() + " " + Getnumer_karty() + " " + to_string(Getmiesiac()) + " " + to_string(Getrok());
  99.  
  100.     }
  101.  
  102.  
  103.     bool Transakcja(int wartosc_rzeczywista) {
  104.  
  105.         if (wydatki_biezace + wartosc_rzeczywista <= limit_kredytu)
  106.         {
  107.             wydatki_biezace = wydatki_biezace + wartosc_rzeczywista;
  108.             return true;
  109.         }
  110.         else return false;
  111.     }
  112.  
  113.     void  Splata(int wysokosc_splaty) {
  114.  
  115.         wydatki_biezace = wydatki_biezace - wysokosc_splaty;
  116.  
  117.     }
  118.  
  119. };
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127. int main()
  128. {
  129.  
  130.     KartaPlatnicza *wsk1 = new KartaKredytowa("s", "b", 12, 12, 123);
  131.     KartaPlatnicza *wsk2 = new KartaKredytowa("fdg", "hjk", 1567, 12, 123);;
  132.     KartaPlatnicza *wsk3 = new KartaKredytowa("dsfgdf", "ghj", 167, 12, 123);;
  133.  
  134.  
  135.     wsk1->Setmiesiac(12);
  136.     wsk2->Setrok(11);
  137.     wsk3->Setnazwa("jkhg");
  138.  
  139.     cout << wsk1->DaneKarty();
  140.  
  141.     ((KartaKredytowa)wsk1)->Transakcja(10);
  142.  
  143.     delete wsk1;
  144.     delete wsk2;
  145.     delete wsk3;
  146.  
  147.     system("pause");
  148.     return 0;
  149. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement