SlideShare une entreprise Scribd logo
1  sur  2
Télécharger pour lire hors ligne
BLG332E
Object Oriented Programming
Practice Session 3
Exercise 4
In this exercise, you create a simple version of the Account class. A test program,
TestBanking.cpp, has been written that creates a single account.
Task 1: Change your working directory to chap03/exercise4
Task 2: Create a class Account that implements the UML diagram given above.
a) Declare one private attribute: balance; tis attribute holds the current (or “running”) balance of
the bank account.
b) Declare a public constructor that takes one parameter (init_balance) that populates the
balance attribute.
c) Declare a public method getBalance that retrieves the current balance.
d) Declare a public method deposit that adds the amount parameter to the current balance.
e) Declare a public method withdraw that removes the amount parameter from the current
balance.
Task 3: Read the TestBanking.cpp code.
Task 4: Compile Account.cpp and TestBanking.cpp.
Task 5: Run the program. You should see the following output:
Create an account with 500.0 balance
Withdraw 150.0
Deposit 22.50
Withdraw 47.62
The account has a balance of 324.88
Exercise 5
In this exercise you will expand the Banking project by adding a Customer class. A customer will
contain one Account object.
Task 1: Change your working directory to chap03/exercise5
Task 2: Copy Account class from the previous exercise lab
cp ../exercise4/Account.* .
Task 2: Create a class Customer class that implements the above UML diagram
a) Declare three private attributes: firstName, lastName, and account.
b) Declare a public constructor that takes two parameters (f and l) that populate the object
attributes.
c) Declare two public accessors for the object attributes; the methods getFirstName and
getlastName return the appropriate attribute.
d) Declare a public method setAccount to assign the account attribute.
e) Declare a public method getAccount to retrieve the account attribute.
f)
Task 3: Read the TestBanking.cpp code.
Task 4: Compile Account.cpp, Customer.cpp, and TestBanking.cpp.
Task 5: Run the program. The output generated should be:
Creating the Customer Jane Smith
Creating her account with a 500.0 balance.
Withdraw 150.0
Deposit 22.50
Withdraw 47.62
Customer [Smith, Jane] has a balance of 324.88
Exercise 6
In this exercise, you will modify the withdraw method to return a boolean value to specify whether the
transaction was successful.
Task 1: Change your working directory to chap03/exercise6
Task 2: You can copy the Account.* and Customer.* files you created in Exercise 5.
Task 3: Modify the Account class to place conditions on the withdraw and deposit methods.
a) Modify the deposit method to return true.
b) Modify the withdraw method to check that the amount being withdrawn is not greater
than the current balance. If amt is less than balance, then subtract the amount from the
balance and return true; else leave the balance alone and return false.
Task 4: Read the TestBanking.cpp code.
Task 5: Compile Account.cpp, Customer.cpp, and TestBanking.cpp.
Task 6: Run the program. The output generated should be:
Creating the Customer Jane Smith
Creating her account with a 500.0 balance.
Withdraw 150.0:true
Deposit 22.50: true
Withdraw 47.62: false
Withdraw 400.0: false
Customer [Smith, Jane] has a balance of 324.88

Contenu connexe

En vedette

Totvs certificado programacao advpl
Totvs certificado programacao advplTotvs certificado programacao advpl
Totvs certificado programacao advplDiego Danna
 
Induksi salam
Induksi salamInduksi salam
Induksi salamffarrah
 
EDUCA A TUS HIJOS CON UN POCO DE HAMBRE Y UN POCO DE FRIO
EDUCA A TUS HIJOS CON UN POCO DE HAMBRE Y UN POCO DE FRIO EDUCA A TUS HIJOS CON UN POCO DE HAMBRE Y UN POCO DE FRIO
EDUCA A TUS HIJOS CON UN POCO DE HAMBRE Y UN POCO DE FRIO jarissalamejordelmundo
 
Estaciones fijas
Estaciones fijasEstaciones fijas
Estaciones fijaskaerinik
 

En vedette (9)

Amor en llamas
Amor en llamasAmor en llamas
Amor en llamas
 
Totvs certificado programacao advpl
Totvs certificado programacao advplTotvs certificado programacao advpl
Totvs certificado programacao advpl
 
1424959218142Certificate
1424959218142Certificate1424959218142Certificate
1424959218142Certificate
 
Railway
RailwayRailway
Railway
 
Exemplos
ExemplosExemplos
Exemplos
 
Induksi salam
Induksi salamInduksi salam
Induksi salam
 
EDUCA A TUS HIJOS CON UN POCO DE HAMBRE Y UN POCO DE FRIO
EDUCA A TUS HIJOS CON UN POCO DE HAMBRE Y UN POCO DE FRIO EDUCA A TUS HIJOS CON UN POCO DE HAMBRE Y UN POCO DE FRIO
EDUCA A TUS HIJOS CON UN POCO DE HAMBRE Y UN POCO DE FRIO
 
Prezentimii3
Prezentimii3Prezentimii3
Prezentimii3
 
Estaciones fijas
Estaciones fijasEstaciones fijas
Estaciones fijas
 

Similaire à 10

Comp 220 ilab 3 of 7
Comp 220 ilab 3 of 7Comp 220 ilab 3 of 7
Comp 220 ilab 3 of 7ashhadiqbal
 
Comp 220 ilab 3 of 7
Comp 220 ilab 3 of 7Comp 220 ilab 3 of 7
Comp 220 ilab 3 of 7solutionjug4
 
CIS 247C iLab 4 of 7: Composition and Class Interfaces
CIS 247C iLab 4 of 7: Composition and Class Interfaces  CIS 247C iLab 4 of 7: Composition and Class Interfaces
CIS 247C iLab 4 of 7: Composition and Class Interfaces HomeWork-Fox
 
Cis247 a ilab 4 composition and class interfaces
Cis247 a ilab 4 composition and class interfacesCis247 a ilab 4 composition and class interfaces
Cis247 a ilab 4 composition and class interfacesccis224477
 
Cis247 a ilab 4 composition and class interfaces
Cis247 a ilab 4 composition and class interfacesCis247 a ilab 4 composition and class interfaces
Cis247 a ilab 4 composition and class interfacesccis224477
 
Cis247 i lab 4 composition and class interfaces
Cis247 i lab 4 composition and class interfacesCis247 i lab 4 composition and class interfaces
Cis247 i lab 4 composition and class interfacessdjdskjd9097
 
Cis247 a ilab 4 composition and class interfaces
Cis247 a ilab 4 composition and class interfacesCis247 a ilab 4 composition and class interfaces
Cis247 a ilab 4 composition and class interfacescis247
 
Assignment Instructions 2_7aExplain the interrelationships bet.docx
Assignment Instructions 2_7aExplain the interrelationships bet.docxAssignment Instructions 2_7aExplain the interrelationships bet.docx
Assignment Instructions 2_7aExplain the interrelationships bet.docxssuser562afc1
 
Please distinguish between the .h and .cpp file, create a fully work.pdf
Please distinguish between the .h and .cpp file, create a fully work.pdfPlease distinguish between the .h and .cpp file, create a fully work.pdf
Please distinguish between the .h and .cpp file, create a fully work.pdfneerajsachdeva33
 
Account.h Definition of Account class. #ifndef ACCOUNT_H #d.pdf
Account.h  Definition of Account class. #ifndef ACCOUNT_H #d.pdfAccount.h  Definition of Account class. #ifndef ACCOUNT_H #d.pdf
Account.h Definition of Account class. #ifndef ACCOUNT_H #d.pdfanujmkt
 
1-What are the opportunities and threats that could impact the org
1-What are the opportunities and threats that could impact the org1-What are the opportunities and threats that could impact the org
1-What are the opportunities and threats that could impact the orgAbbyWhyte974
 
1-What are the opportunities and threats that could impact the org
1-What are the opportunities and threats that could impact the org1-What are the opportunities and threats that could impact the org
1-What are the opportunities and threats that could impact the orgMartineMccracken314
 
Lab 2: Importing requirements artifacts from a CSV file
Lab 2: Importing requirements artifacts from a CSV file Lab 2: Importing requirements artifacts from a CSV file
Lab 2: Importing requirements artifacts from a CSV file IBM Rational software
 
Comp 220 i lab 3 bank account lab report and source code
Comp 220 i lab 3 bank account lab report and source codeComp 220 i lab 3 bank account lab report and source code
Comp 220 i lab 3 bank account lab report and source codepradesigali1
 
Cis247 i lab 5 inheritance
Cis247 i lab 5 inheritanceCis247 i lab 5 inheritance
Cis247 i lab 5 inheritancesdjdskjd9097
 
Java: Class Design Examples
Java: Class Design ExamplesJava: Class Design Examples
Java: Class Design ExamplesTareq Hasan
 
Cis247 a ilab 5 inheritance
Cis247 a ilab 5 inheritanceCis247 a ilab 5 inheritance
Cis247 a ilab 5 inheritanceccis224477
 

Similaire à 10 (20)

Comp 220 ilab 3 of 7
Comp 220 ilab 3 of 7Comp 220 ilab 3 of 7
Comp 220 ilab 3 of 7
 
Comp 220 ilab 3 of 7
Comp 220 ilab 3 of 7Comp 220 ilab 3 of 7
Comp 220 ilab 3 of 7
 
CIS 247C iLab 4 of 7: Composition and Class Interfaces
CIS 247C iLab 4 of 7: Composition and Class Interfaces  CIS 247C iLab 4 of 7: Composition and Class Interfaces
CIS 247C iLab 4 of 7: Composition and Class Interfaces
 
Comp 220 lab 3
Comp 220 lab 3Comp 220 lab 3
Comp 220 lab 3
 
T4
T4T4
T4
 
Cis247 a ilab 4 composition and class interfaces
Cis247 a ilab 4 composition and class interfacesCis247 a ilab 4 composition and class interfaces
Cis247 a ilab 4 composition and class interfaces
 
Cis247 a ilab 4 composition and class interfaces
Cis247 a ilab 4 composition and class interfacesCis247 a ilab 4 composition and class interfaces
Cis247 a ilab 4 composition and class interfaces
 
Cis247 i lab 4 composition and class interfaces
Cis247 i lab 4 composition and class interfacesCis247 i lab 4 composition and class interfaces
Cis247 i lab 4 composition and class interfaces
 
Cis247 a ilab 4 composition and class interfaces
Cis247 a ilab 4 composition and class interfacesCis247 a ilab 4 composition and class interfaces
Cis247 a ilab 4 composition and class interfaces
 
Assignment Instructions 2_7aExplain the interrelationships bet.docx
Assignment Instructions 2_7aExplain the interrelationships bet.docxAssignment Instructions 2_7aExplain the interrelationships bet.docx
Assignment Instructions 2_7aExplain the interrelationships bet.docx
 
Please distinguish between the .h and .cpp file, create a fully work.pdf
Please distinguish between the .h and .cpp file, create a fully work.pdfPlease distinguish between the .h and .cpp file, create a fully work.pdf
Please distinguish between the .h and .cpp file, create a fully work.pdf
 
Account.h Definition of Account class. #ifndef ACCOUNT_H #d.pdf
Account.h  Definition of Account class. #ifndef ACCOUNT_H #d.pdfAccount.h  Definition of Account class. #ifndef ACCOUNT_H #d.pdf
Account.h Definition of Account class. #ifndef ACCOUNT_H #d.pdf
 
1-What are the opportunities and threats that could impact the org
1-What are the opportunities and threats that could impact the org1-What are the opportunities and threats that could impact the org
1-What are the opportunities and threats that could impact the org
 
1-What are the opportunities and threats that could impact the org
1-What are the opportunities and threats that could impact the org1-What are the opportunities and threats that could impact the org
1-What are the opportunities and threats that could impact the org
 
Lab 2: Importing requirements artifacts from a CSV file
Lab 2: Importing requirements artifacts from a CSV file Lab 2: Importing requirements artifacts from a CSV file
Lab 2: Importing requirements artifacts from a CSV file
 
Comp 220 i lab 3 bank account lab report and source code
Comp 220 i lab 3 bank account lab report and source codeComp 220 i lab 3 bank account lab report and source code
Comp 220 i lab 3 bank account lab report and source code
 
Cis247 i lab 5 inheritance
Cis247 i lab 5 inheritanceCis247 i lab 5 inheritance
Cis247 i lab 5 inheritance
 
11 job costing
11 job costing11 job costing
11 job costing
 
Java: Class Design Examples
Java: Class Design ExamplesJava: Class Design Examples
Java: Class Design Examples
 
Cis247 a ilab 5 inheritance
Cis247 a ilab 5 inheritanceCis247 a ilab 5 inheritance
Cis247 a ilab 5 inheritance
 

Plus de liankei (20)

Lo 19
Lo 19Lo 19
Lo 19
 
Lo 18
Lo 18Lo 18
Lo 18
 
Lo 13
Lo 13Lo 13
Lo 13
 
Lo 12
Lo 12Lo 12
Lo 12
 
Lo 11
Lo 11Lo 11
Lo 11
 
Lo 06
Lo 06Lo 06
Lo 06
 
Lo 05
Lo 05Lo 05
Lo 05
 
Lo 04
Lo 04Lo 04
Lo 04
 
Lo 01
Lo 01Lo 01
Lo 01
 
Lo 16
Lo 16Lo 16
Lo 16
 
Lo 15
Lo 15Lo 15
Lo 15
 
Lo 09
Lo 09Lo 09
Lo 09
 
Lo 08
Lo 08Lo 08
Lo 08
 
Lo 03
Lo 03Lo 03
Lo 03
 
Lo 20
Lo 20Lo 20
Lo 20
 
Lo19
Lo19Lo19
Lo19
 
Lo20
Lo20Lo20
Lo20
 
Lo17
Lo17Lo17
Lo17
 
Lo18
Lo18Lo18
Lo18
 
Lo15
Lo15Lo15
Lo15
 

Dernier

Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 

Dernier (20)

Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 

10

  • 1. BLG332E Object Oriented Programming Practice Session 3 Exercise 4 In this exercise, you create a simple version of the Account class. A test program, TestBanking.cpp, has been written that creates a single account. Task 1: Change your working directory to chap03/exercise4 Task 2: Create a class Account that implements the UML diagram given above. a) Declare one private attribute: balance; tis attribute holds the current (or “running”) balance of the bank account. b) Declare a public constructor that takes one parameter (init_balance) that populates the balance attribute. c) Declare a public method getBalance that retrieves the current balance. d) Declare a public method deposit that adds the amount parameter to the current balance. e) Declare a public method withdraw that removes the amount parameter from the current balance. Task 3: Read the TestBanking.cpp code. Task 4: Compile Account.cpp and TestBanking.cpp. Task 5: Run the program. You should see the following output: Create an account with 500.0 balance Withdraw 150.0 Deposit 22.50 Withdraw 47.62 The account has a balance of 324.88 Exercise 5 In this exercise you will expand the Banking project by adding a Customer class. A customer will contain one Account object. Task 1: Change your working directory to chap03/exercise5 Task 2: Copy Account class from the previous exercise lab cp ../exercise4/Account.* .
  • 2. Task 2: Create a class Customer class that implements the above UML diagram a) Declare three private attributes: firstName, lastName, and account. b) Declare a public constructor that takes two parameters (f and l) that populate the object attributes. c) Declare two public accessors for the object attributes; the methods getFirstName and getlastName return the appropriate attribute. d) Declare a public method setAccount to assign the account attribute. e) Declare a public method getAccount to retrieve the account attribute. f) Task 3: Read the TestBanking.cpp code. Task 4: Compile Account.cpp, Customer.cpp, and TestBanking.cpp. Task 5: Run the program. The output generated should be: Creating the Customer Jane Smith Creating her account with a 500.0 balance. Withdraw 150.0 Deposit 22.50 Withdraw 47.62 Customer [Smith, Jane] has a balance of 324.88 Exercise 6 In this exercise, you will modify the withdraw method to return a boolean value to specify whether the transaction was successful. Task 1: Change your working directory to chap03/exercise6 Task 2: You can copy the Account.* and Customer.* files you created in Exercise 5. Task 3: Modify the Account class to place conditions on the withdraw and deposit methods. a) Modify the deposit method to return true. b) Modify the withdraw method to check that the amount being withdrawn is not greater than the current balance. If amt is less than balance, then subtract the amount from the balance and return true; else leave the balance alone and return false. Task 4: Read the TestBanking.cpp code. Task 5: Compile Account.cpp, Customer.cpp, and TestBanking.cpp. Task 6: Run the program. The output generated should be: Creating the Customer Jane Smith Creating her account with a 500.0 balance. Withdraw 150.0:true Deposit 22.50: true Withdraw 47.62: false Withdraw 400.0: false Customer [Smith, Jane] has a balance of 324.88