C++ programming

profilerajiv012
Lab2ClassesandDataAbstraction.pdf

C++ Programming: Program Design Including Data Structures 10-1

Chapter 10

Classes and Data Abstraction Overview

Chapter 10 introduces a structured data type called a class, which is specifically designed to group data and functions. After examining its structure, you will learn how to create and use classes. The typical members of a class will be discussed, including accessors, mutators, constructors, and destructors. We will define the properties of these members, such as ​private​, ​protected​, ​public​, and ​static​. You will also learn about abstract data types and how classes are used to implement them. In the process, you will be introduced to the concept of information hiding. Finally, we will discuss information hiding as implemented in C++.

Objectives In this chapter, the student will:

● Learn about classes ● Learn about ​private​, ​protected​, and ​public​ members of a class ● Explore how classes are implemented ● Become aware of accessor and mutator functions ● Examine constructors and destructors ● Learn about the abstract data type (ADT) ● Explore how classes are used to implement ADTs ● Learn about information hiding ● Explore how information hiding is implemented in C++ ● Learn about the ​static​ members of a class

Assignment

1. Read Chapter 10 in your book.

2. View the Chapter 10 Lecture Videos

3. Complete Chapter 10 Quiz.

4. Complete Programming Exercise 18 on page 735. See details on the next page

a. You will be creating three files. The bankAccount.h file, the implementation of the bankAccount Class cpp file and the test drive cpp file with the main function to test your class.

b. The class needs to have at least these methods:

© 2015 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.

C++ Programming: Program Design Including Data Structures 10-2

i. The constructor ii. Set the data (name, account type, balance, interest rate)

iii. Deposit – receives amount of deposit iv. Withdraw – receives amount of withdraw v. Get the Interest Rate – returns the interest rate

vi. Get Account Number – returns the account number vii. Get the Account Holders Name – returns the name

viii. Get the Account Type – returns the account type ix. Get the balance – returns the balance x. Print – nice output of one account and all of its information

c. Your test driver needs to test all of the methods. It needs to allow the user to enter a new account,

make a deposit and withdraw. Every time you deposit or withdraw, print all of the account information so the user can see the change was made.

d. Submit the project and a screenshot of the program running. i. Create one folder and put in the one folder the following: screenshot, bankAccount.h,

bankAccount.cpp, and bankAccountDriver.cpp ii. Compress the Folder. Name your compressed folder LastNameFirstInitial Lab2. Example.

SerranoGLab2.zip

Submit Assignment Now you are ready to submit your assignment for grading. Upload your assignment through eCampus (Blackboard). The link to submit your assignment is located at the same place you found these lab instructions in eCampus. Your instructor will post your grade in the eCampus gradebook. Select the ​My Grades​ link or button to view your grade. You are done with Lab 2.

© 2015 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.