Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Programming please do in C++ visual studio easy: Inheritance and Polymorphism The classes (base and derived) all have been defined and written, you are

C++ Programming please do in C++ visual studio
easy: Inheritance and Polymorphism
The classes (base and derived) all have been defined and written, you are just writing extra member functions and follow the instructions in the given question.
I already attached the code to help you
very easy I give u likes likes #include"cards.h"
-------------------------------------------------------
Main.cpp
using namespace std;
int main()
{
vector wallet;
cout
int type;
Card* mycard = NULL;
while (true)
{
cout
cin >> type;
if (type == 1)
mycard = new Card();
else if (type == 2)
mycard = new IDcard();
else if (type == 3)
mycard = new BankCard();
else
break;
wallet.push_back(mycard);
}
for (int i=0; i
{
wallet[i]->display();
delete wallet[i];
}
return 0;
}
-------------------------------------------------------
cards.h
#ifndef __CARDS_H__
#define __CARDS_H__
#include
#include
#include
#include
class Card
{
public:
Card();
virtual void display() const;
virtual ~Card(){};
private:
std::string holder; // card holder name
std::string organization; // organization name
std::string number; // card number
std::string expiration; // expiration date
};
class IDcard: public Card
{
public:
IDcard();
virtual void display() const;
virtual ~IDcard(){};
private:
std::string DOB; // MMDDYYYY
};
class BankCard: public Card
{
public:
BankCard();
virtual void display() const;
virtual ~BankCard(){};
private:
std::string account_number;
std::string security_code;
};
#endif
-------------------------------------------------------
cards.cpp
#include"cards.h"
// constructor of Card class
Card::Card()
{
std::cout
std::cin.ignore();
std::getline( std::cin, holder);
std::cout
std::getline( std::cin, organization);
std::cout
std::cin.ignore();
std::cin >> number;
std::cout
std::cin >> expiration;
}
void Card::display() const
{
std::cout
std::cout
std::cout
std::cout
}
IDcard::IDcard():Card()
{
std::cout
std::cin >> DOB;
}
void IDcard::display() const
{
Card::display();
std::cout
}
//
BankCard::BankCard():Card()
{
std::cout
std::cin >> account_number;
std::cout
std::cin >> security_code;
}
void BankCard::display() const
{
Card::display();
std::cout
std::cout
}
Oh I forgot to attach the instructions LOLL
image text in transcribed
image text in transcribed
image text in transcribed
Problem 1 (60pt): Use classes Card, IDCard and BankCard from Homework 2 and add more features for them. For Card class, create a member function to determine if the card is expired at certain date. The card is NOT expired if the current date is the same as its expiration date or the card doesn't have an expiration date. For IDCard class, create a member function to compute the age of the card holder at certain date. The card holder's age increases I on their birthdays The program promotes the user to enter the date, which is of the format MMDDYYYY and prints out accordingly information using polymorphism. Follow the format shown in the output sample exactly (refer to Homework 2) and abide by good coding practices. Instructions: . (10pt) Separate your code into three files Cards. h, Cards.cpp and main.cpp and sub- mit them to ccle.ucla.edu. Write your code with good coding practices. Comment on your code to make it readable and add description of files in the beginning to show your ownership (50pt) Compile your code and run your program to check for compile-time errors and logic errors. Your output should follow the format as follows. Remember to check your homework with PIC lab desktop if you don't code with VS 2019. You may lose the majority of points if your code doesn't compile. ** Print Cards ESSERE Enter card information by selecting type (when done) 1. Basic Card 2. ID Card 3. Bank Card Card type: 1 Card holder nome: Joke P. Organization name: BruinClub Card number: BC102 Expiration date (MMDDYYYY), enter NA If none: 03312820 Enter card information by selecting type (when done) 1. Basic Card 2. ID Card 3. Bank Card Card type: 2 Card holder nome: Any S. Organization name: NYPD Card number: BY123 Expiration date (MMDDYYYY), enter N/A if none: N/A Date of Birth (MMOOYYYY): 03311990 Enter card information by selecting type ( when done) 1. Basic Card 2. ID Card 3. Bank Card Card type: a Please enter today's date (DOYYYY): 3312eze BruinClub Nome: Jake P. Expiration date: 83312020 If expirated: No NYPO Nome: Any S. Expiration date: N/A If expirated: No Date of Birth: 03311992 Problem 1 (60pt): Use classes Card, IDCard and BankCard from Homework 2 and add more features for them. For Card class, create a member function to determine if the card is expired at certain date. The card is NOT expired if the current date is the same as its expiration date or the card doesn't have an expiration date. For IDCard class, create a member function to compute the age of the card holder at certain date. The card holder's age increases 1 on their birthdays. The program promotes the user to enter the date, which is of the format MMDDYYYY, and prints out accordingly information using polymorphism. Follow the format shown in the output sample exactly (refer to Homework 2) and abide by good coding practices. SOSSEGESSO Print Cards SESEOSESES Enter card information by selecting type (@when done) 1. Basic Card 2. ID Card 3. Bank Card Card type: 1 Card holder name: Jake P. Organization name: BruinClub Card number: BC102 Expiration date (MMDDYYYY), enter N/A if none: 03312020 Enter card information by selecting type (@when done) 1. Basic Card 2. ID Card 3. Bank Card Card type: 2 Card holder name: Amy S. Organization name: NYPD Card number: BY123 Expiration date (MMDDYYYY), enter N/A if none: N/A Date of Birth (MMDDYYYY): 03311990 Enter card information by selecting type (@when done) 1. Basic Card 2. ID Card 3 .Bank Card Card type: 0 Please enter today's date (MMDDYYYY): 03312020 BruinClub Name: Jake P. Expiration date: 03312020 If expirated: No NYPD Name: Amy S. Expiration date: N/A If expirated: No Date of Birth: 03311990 Age: 30 Problem 1 (60pt): Use classes Card, IDCard and BankCard from Homework 2 and add more features for them. For Card class, create a member function to determine if the card is expired at certain date. The card is NOT expired if the current date is the same as its expiration date or the card doesn't have an expiration date. For IDCard class, create a member function to compute the age of the card holder at certain date. The card holder's age increases I on their birthdays The program promotes the user to enter the date, which is of the format MMDDYYYY and prints out accordingly information using polymorphism. Follow the format shown in the output sample exactly (refer to Homework 2) and abide by good coding practices. Instructions: . (10pt) Separate your code into three files Cards. h, Cards.cpp and main.cpp and sub- mit them to ccle.ucla.edu. Write your code with good coding practices. Comment on your code to make it readable and add description of files in the beginning to show your ownership (50pt) Compile your code and run your program to check for compile-time errors and logic errors. Your output should follow the format as follows. Remember to check your homework with PIC lab desktop if you don't code with VS 2019. You may lose the majority of points if your code doesn't compile. ** Print Cards ESSERE Enter card information by selecting type (when done) 1. Basic Card 2. ID Card 3. Bank Card Card type: 1 Card holder nome: Joke P. Organization name: BruinClub Card number: BC102 Expiration date (MMDDYYYY), enter NA If none: 03312820 Enter card information by selecting type (when done) 1. Basic Card 2. ID Card 3. Bank Card Card type: 2 Card holder nome: Any S. Organization name: NYPD Card number: BY123 Expiration date (MMDDYYYY), enter N/A if none: N/A Date of Birth (MMOOYYYY): 03311990 Enter card information by selecting type ( when done) 1. Basic Card 2. ID Card 3. Bank Card Card type: a Please enter today's date (DOYYYY): 3312eze BruinClub Nome: Jake P. Expiration date: 83312020 If expirated: No NYPO Nome: Any S. Expiration date: N/A If expirated: No Date of Birth: 03311992 Problem 1 (60pt): Use classes Card, IDCard and BankCard from Homework 2 and add more features for them. For Card class, create a member function to determine if the card is expired at certain date. The card is NOT expired if the current date is the same as its expiration date or the card doesn't have an expiration date. For IDCard class, create a member function to compute the age of the card holder at certain date. The card holder's age increases 1 on their birthdays. The program promotes the user to enter the date, which is of the format MMDDYYYY, and prints out accordingly information using polymorphism. Follow the format shown in the output sample exactly (refer to Homework 2) and abide by good coding practices. SOSSEGESSO Print Cards SESEOSESES Enter card information by selecting type (@when done) 1. Basic Card 2. ID Card 3. Bank Card Card type: 1 Card holder name: Jake P. Organization name: BruinClub Card number: BC102 Expiration date (MMDDYYYY), enter N/A if none: 03312020 Enter card information by selecting type (@when done) 1. Basic Card 2. ID Card 3. Bank Card Card type: 2 Card holder name: Amy S. Organization name: NYPD Card number: BY123 Expiration date (MMDDYYYY), enter N/A if none: N/A Date of Birth (MMDDYYYY): 03311990 Enter card information by selecting type (@when done) 1. Basic Card 2. ID Card 3 .Bank Card Card type: 0 Please enter today's date (MMDDYYYY): 03312020 BruinClub Name: Jake P. Expiration date: 03312020 If expirated: No NYPD Name: Amy S. Expiration date: N/A If expirated: No Date of Birth: 03311990 Age: 30

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2014 Administration

Authors: Adam Jorgensen, Bradley Ball

1st Edition

111885926X, 9781118859261

More Books

Students also viewed these Databases questions