Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Łukasz.cpp : main project file.
- #include "stdafx.h"
- #include <iostream>
- #include <string>
- using namespace std;
- class KartaPlatnicza {
- private:
- string numer_karty;
- string nazwa;
- int miesiac;
- int rok;
- public:
- KartaPlatnicza() {
- numer_karty = "0000 0000 0000 0000";
- nazwa = "brak";
- miesiac = 1;
- rok = 2018;
- }
- KartaPlatnicza(string numer, string n, int msc, int r) : numer_karty(numer), nazwa(n), miesiac(msc), rok(r)
- {
- }
- string Getnumer_karty() {
- return numer_karty;
- }
- void Setnumer_karty(string numer) {
- numer_karty = numer;
- }
- string Getnazwa() {
- return nazwa;
- }
- void Setnazwa(string name) {
- nazwa = name;
- }
- int Getmiesiac() {
- return miesiac;
- }
- void Setmiesiac(int month) {
- miesiac = month;
- }
- int Getrok() {
- return rok;
- }
- void Setrok(int year) {
- rok = year;
- }
- string virtual DaneKarty() {};
- };
- class KartaKredytowa :public KartaPlatnicza {
- private:
- int limit_kredytu;
- int wydatki_biezace;
- public:
- KartaKredytowa(string nk, string naz, int m, int ro, int limit) :KartaPlatnicza(nk, naz, m, ro) {
- wydatki_biezace = 0;
- }
- string DaneKarty() {
- return Getnazwa() + " " + Getnumer_karty() + " " + to_string(Getmiesiac()) + " " + to_string(Getrok());
- }
- bool Transakcja(int wartosc_rzeczywista) {
- if (wydatki_biezace + wartosc_rzeczywista <= limit_kredytu)
- {
- wydatki_biezace = wydatki_biezace + wartosc_rzeczywista;
- return true;
- }
- else return false;
- }
- void Splata(int wysokosc_splaty) {
- wydatki_biezace = wydatki_biezace - wysokosc_splaty;
- }
- };
- int main()
- {
- KartaPlatnicza *wsk1 = new KartaKredytowa("s", "b", 12, 12, 123);
- KartaPlatnicza *wsk2 = new KartaKredytowa("fdg", "hjk", 1567, 12, 123);;
- KartaPlatnicza *wsk3 = new KartaKredytowa("dsfgdf", "ghj", 167, 12, 123);;
- wsk1->Setmiesiac(12);
- wsk2->Setrok(11);
- wsk3->Setnazwa("jkhg");
- cout << wsk1->DaneKarty();
- ((KartaKredytowa)wsk1)->Transakcja(10);
- delete wsk1;
- delete wsk2;
- delete wsk3;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement