Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Credit Card and Person Classes (C++ programming) For this lab, you will create two classes, a Person class and a Credit Card class that uses

Credit Card and Person Classes (C++ programming)

For this lab, you will create two classes, a Person class and a Credit Card class that uses the Person class.

- Program Design

+ For this assignment, you will be setting up a program that represents a credit card. The card will have a card number, balance, credit limit and an account owner. Because the account owner is represented by common data elements like name and address that apply to many scenarios, we are going to represent that information with a generic Person class, which we will then be able to reuse in the future. Thus, for this assignment, you will be writing two classes: a CreditCard class that contains information about a credit account, and a Person class which contains basic biographical information about a person.

+ You will create the two classes and then use the provided test program to make sure it works. This means that your class and methods must match the names used in the test program. You will have a total of five files; the main test program that is provided, Person.h, Person.cpp, CreditCard.h, and CreditCard.cpp.

+ CreditCard.h will include Person.h in order to allow the two classes to work properly together.

+ When all is working, you should zip up your complete project and submit it.

-Program Requirements

The CreditCard class should support the following functions:

1. Constructor the constructor should take a first and last name, address, card number, and credit limit. Your CreditCard class should have a Person variable. This constructor will then initialize that person variable by calling the set functions contained in the Person class (see below)

2. getBalance returns the current card balance (as a double)

3. getCardNumber returns the card number

4. getOwnerName returns the first and last name of the card owner

5. getAddress returns the card holders address

6. payBalance this function takes a double value as an argument and applies that payment to the balance. Payments must be non-negative values, but a negative balance is acceptable. This function should return a Boolean value: true if the payment was applied and false if it was not (due to negative payment amount).

7. makeCharge this function takes a double value and charges that amount to the card, Credit Card and Person Classes increasing the balance. Charges must be positive and cannot cause the balance to exceed the credit limit. This function should return a Boolean: true if the charge could was applied, false otherwise.

8. setCreditLimit This function takes a double and sets the credit limit to a new value. Note that the credit limit may be set to a value that is below the current balance, but it cannot be set to a negative value.

The Person class should support the following functions:

1. Default constructor

2. Constructor which accepts a first name, last name, and address

3. get and set function for the first name, last name, and address

- Program Hints

+ Create your Person class and make sure that is working with your own test program.

+ Then create the CreditCard class and include a Person in it. Get the basic methods working fine (constructor, getBalance, getOwnerName, getAddress). Finally add the other methods and test the entire program.

+ Note that getOwnerName will call getFirstName and getLastName from the Person and put together an ownerName.

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

Select Healthcare Classification Systems And Databases

Authors: Katherine S. Rowell, Ann Cutrell

1st Edition

0615909760, 978-0615909769

More Books

Students also viewed these Databases questions