SlideShare a Scribd company logo
1 of 18
CSC139 Chapter 9 Lab Assignments (1)
Classes and Objects
Objectives
In this lab assignment, students will learn:
- How to design and define class
- How to create object
- How to define a tester program to test the object
Goals
In this lab assignment, students will demonstrate the abilities
to:
- Design and define class
- Create object
- Define a tester program to test the object
Grading
- Design and create a GUI (20 pts)
- Design and define class (40 pts)
- Define tester program (40 pts)
Develop a "
BankAccount
" windows form project, which will allow user to
- Enter amount of money to deposit, withdraw or move
- Deposit money in checking or savings account.
- Withdraw money from checking or savings account.
- Move money between checking account and saving account.
- View the new balance on the form after each transaction.
Here is sample input/output:
When start to run project, initial balances for both checking and
saving accounts ($1000.00) should be displayed on the form.
After deposit $500.00 to checking account.
After move $800.00 from saving to checking account.
If user attempts to withdraw $4000.00 from checking account at
this moment, a MessageBox should be displayed with an error
message.
Project specifications --------
1. This project should perform object-oriented programming.
Add a class file "Account.vb" to define class "Account", rename
"Form1.vb" file as "AccountTesterForm.vb" which will create
account object and test the object’s attributes and behaviors.
2.
This is the GUI for the bank. The amount of money need to be
entered from the textbox, each button represents a type of
transaction. The new balance will be displayed on the form after
each transaction.
Please use the same control names in order to use the tester
program code below.
balanceLabel
amountTextBox
moveStoCButton
withdrawSavingButton
depositSavingButton
moveCtoSButton
depositCheckingButton
withdrawCheckingButton
3.
Here is the definition of class Account, some codes are missing,
you may copy the code to your project in Visual Studio and
complete the missing code.
Public Class Account
Private savingBalance As Decimal 'instance variable for balance
in saving account
Private checkingBalance As Decimal 'instance variable for
balance in checking account
'constructor which initialize balances in both accounts to
1000.00
Public Sub New()
savingBalance = 1000.0
checkingBalance = 1000.0
End Sub
'property for savingBalance
Public Property Saving() As Double
Get
Return savingBalance
End Get
Set(ByVal value As Double)
If value < 0 Then
savingBalance = 0
Else
savingBalance = value
End If
End Set
End Property
'property for checkingBalance
Public Property Checking() As Double
'write your code here
End Property
'define how to deposit money to checking account
Public Sub depositChecking(ByVal amount As Decimal)
'write your code here
End Sub
'define how to deposit money to saving account
Public Sub depositSaving(ByVal amount As Decimal)
'write your code here
End Sub
'define how to withdraw money from checking account
Public Sub withdrawChecking(ByVal amount As Decimal)
If amount > Checking Then
Throw New ArgumentOutOfRangeException(
"Withdrawal amount must be less than or equal to balance.")
ElseIf amount <= 0D Then
Throw New ArgumentOutOfRangeException(
"Withrawal amount must be positive.")
End If
Checking -= amount
End Sub
'define how to withdraw money from saving account
Public Sub withdrawSaving(ByVal amount As Decimal)
'write your code here
End Sub
'define how to move money from checking to saving account
Public Sub moveMoneyCheckingtoSaving(ByVal amount As
Double)
'write your code here
End Sub
'define how to move money from saving to checking account
Public Sub moveMoneySavingtoChecking(ByVal amount As
Double)
'write your code here
End Sub
End Class
4.
Here is the code for accountTesterForm.vb, some codes are
missing, you may copy the code to your project in Visual Studio
and complete the missing code (
The header of event handler methods can NOT be copied, they
need to be created by double clicking the corresponding buttons
).
Option Strict On
Public Class AccountTesterForm
Dim account As New Account()
Private Sub AccountTesterForm_Load(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
displayBalance()
End Sub
Private Sub DepositCheckingButton_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
DepositCheckingButton.Click
Try
account.depositChecking(Convert.ToDecimal(AmountTextBox.
Text))
displayBalance()
Catch ex As ArgumentOutOfRangeException
MessageBox.Show("Deposit amount must be positive.",
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
AmountTextBox.Clear() ' clear the inputTextBox
AmountTextBox.Focus()
End Sub
Private Sub DepositSavingButton_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
DepositSavingButton.Click
'write your code here
End Sub
Private Sub withdrawCheckingButton_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
withdrawCheckingButton.Click
'write your code here
End Sub
Private Sub withdrawSavingButton_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
withdrawSavingButton.Click
'write your code here
End Sub
Private Sub movectosButton_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
movectosButton.Click
'write your code here
End Sub
Private Sub moveStoCButton_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
moveStoCButton.Click
'write your code here
End Sub
Private Sub displayBalance()
balanceLabel.Text = "Checking balance: " &
String.Format("{0:C}", account.Checking) & vbCrLf & "Saving
balance: " & String.Format("{0:C}", account.Saving)
End Sub
End Class

More Related Content

Similar to CSC139 Chapter 9 Lab Assignments (1) Classes and Obj.docx

Dynamics ax 2012 workflow development
Dynamics ax 2012 workflow development Dynamics ax 2012 workflow development
Dynamics ax 2012 workflow development Ahmed Farag
 
Write a banking program that simulates the operation of your local ba.docx
 Write a banking program that simulates the operation of your local ba.docx Write a banking program that simulates the operation of your local ba.docx
Write a banking program that simulates the operation of your local ba.docxajoy21
 
Cbse computer science (c++) class 12 board project bank managment system
Cbse computer science (c++)  class 12 board project  bank managment systemCbse computer science (c++)  class 12 board project  bank managment system
Cbse computer science (c++) class 12 board project bank managment systempranoy_seenu
 
Cis 247 all i labs
Cis 247 all i labsCis 247 all i labs
Cis 247 all i labsccis224477
 
Itco 620 unit 5 project
Itco 620 unit 5 projectItco 620 unit 5 project
Itco 620 unit 5 projectcomp274
 
Banks offer various types of accounts, such as savings, checking, cer.pdf
 Banks offer various types of accounts, such as savings, checking, cer.pdf Banks offer various types of accounts, such as savings, checking, cer.pdf
Banks offer various types of accounts, such as savings, checking, cer.pdfakbsingh1313
 
Vbtutorial
VbtutorialVbtutorial
Vbtutorialdhi her
 
Tang doanh thu quang cao di dong
Tang doanh thu quang cao di dongTang doanh thu quang cao di dong
Tang doanh thu quang cao di dongDuc Canh Tran
 
PT1420 Decision Structures in Pseudocode and Visual Basic .docx
PT1420 Decision Structures in Pseudocode and Visual Basic .docxPT1420 Decision Structures in Pseudocode and Visual Basic .docx
PT1420 Decision Structures in Pseudocode and Visual Basic .docxamrit47
 
Create chart of account
Create chart of accountCreate chart of account
Create chart of accountHassan Fadl
 
Consider this C++ BankAccount class with the following public member.pdf
Consider this C++ BankAccount class with the following public member.pdfConsider this C++ BankAccount class with the following public member.pdf
Consider this C++ BankAccount class with the following public member.pdfarchigallery1298
 
C# Tutorial MSM_Murach chapter-03-slides
C# Tutorial MSM_Murach chapter-03-slidesC# Tutorial MSM_Murach chapter-03-slides
C# Tutorial MSM_Murach chapter-03-slidesSami Mut
 
Tony Vitabile .Net Portfolio
Tony Vitabile .Net PortfolioTony Vitabile .Net Portfolio
Tony Vitabile .Net Portfoliovitabile
 
Demo how to create visualforce page and custom controller via developer console
Demo how to create visualforce page and custom controller via developer consoleDemo how to create visualforce page and custom controller via developer console
Demo how to create visualforce page and custom controller via developer consoletuan vo
 

Similar to CSC139 Chapter 9 Lab Assignments (1) Classes and Obj.docx (17)

Dynamics ax 2012 workflow development
Dynamics ax 2012 workflow development Dynamics ax 2012 workflow development
Dynamics ax 2012 workflow development
 
Write a banking program that simulates the operation of your local ba.docx
 Write a banking program that simulates the operation of your local ba.docx Write a banking program that simulates the operation of your local ba.docx
Write a banking program that simulates the operation of your local ba.docx
 
Cbse computer science (c++) class 12 board project bank managment system
Cbse computer science (c++)  class 12 board project  bank managment systemCbse computer science (c++)  class 12 board project  bank managment system
Cbse computer science (c++) class 12 board project bank managment system
 
Cis 247 all i labs
Cis 247 all i labsCis 247 all i labs
Cis 247 all i labs
 
Itco 620 unit 5 project
Itco 620 unit 5 projectItco 620 unit 5 project
Itco 620 unit 5 project
 
Banks offer various types of accounts, such as savings, checking, cer.pdf
 Banks offer various types of accounts, such as savings, checking, cer.pdf Banks offer various types of accounts, such as savings, checking, cer.pdf
Banks offer various types of accounts, such as savings, checking, cer.pdf
 
SAP SD Training in Chennai
SAP SD Training in Chennai SAP SD Training in Chennai
SAP SD Training in Chennai
 
Vbtutorial
VbtutorialVbtutorial
Vbtutorial
 
Tang doanh thu quang cao di dong
Tang doanh thu quang cao di dongTang doanh thu quang cao di dong
Tang doanh thu quang cao di dong
 
PT1420 Decision Structures in Pseudocode and Visual Basic .docx
PT1420 Decision Structures in Pseudocode and Visual Basic .docxPT1420 Decision Structures in Pseudocode and Visual Basic .docx
PT1420 Decision Structures in Pseudocode and Visual Basic .docx
 
Create chart of account
Create chart of accountCreate chart of account
Create chart of account
 
Consider this C++ BankAccount class with the following public member.pdf
Consider this C++ BankAccount class with the following public member.pdfConsider this C++ BankAccount class with the following public member.pdf
Consider this C++ BankAccount class with the following public member.pdf
 
Creating modeled views
Creating modeled viewsCreating modeled views
Creating modeled views
 
C# Tutorial MSM_Murach chapter-03-slides
C# Tutorial MSM_Murach chapter-03-slidesC# Tutorial MSM_Murach chapter-03-slides
C# Tutorial MSM_Murach chapter-03-slides
 
Tony Vitabile .Net Portfolio
Tony Vitabile .Net PortfolioTony Vitabile .Net Portfolio
Tony Vitabile .Net Portfolio
 
Demo how to create visualforce page and custom controller via developer console
Demo how to create visualforce page and custom controller via developer consoleDemo how to create visualforce page and custom controller via developer console
Demo how to create visualforce page and custom controller via developer console
 
Project1 VB
Project1 VBProject1 VB
Project1 VB
 

More from ruthannemcmullen

Describe how an attacker could use a sniffer in conjunction with a T.docx
Describe how an attacker could use a sniffer in conjunction with a T.docxDescribe how an attacker could use a sniffer in conjunction with a T.docx
Describe how an attacker could use a sniffer in conjunction with a T.docxruthannemcmullen
 
Describe a specific workplace conflict situation involving the compe.docx
Describe a specific workplace conflict situation involving the compe.docxDescribe a specific workplace conflict situation involving the compe.docx
Describe a specific workplace conflict situation involving the compe.docxruthannemcmullen
 
Describe common biases in decision making.Explain the roles of emo.docx
Describe common biases in decision making.Explain the roles of emo.docxDescribe common biases in decision making.Explain the roles of emo.docx
Describe common biases in decision making.Explain the roles of emo.docxruthannemcmullen
 
Describe an example of a television program that you believe clearly.docx
Describe an example of a television program that you believe clearly.docxDescribe an example of a television program that you believe clearly.docx
Describe an example of a television program that you believe clearly.docxruthannemcmullen
 
Describe Abell’s three-dimensional business-definition model and exp.docx
Describe Abell’s three-dimensional business-definition model and exp.docxDescribe Abell’s three-dimensional business-definition model and exp.docx
Describe Abell’s three-dimensional business-definition model and exp.docxruthannemcmullen
 
Describe an example of a contract that you or someone you know enter.docx
Describe an example of a contract that you or someone you know enter.docxDescribe an example of a contract that you or someone you know enter.docx
Describe an example of a contract that you or someone you know enter.docxruthannemcmullen
 
Denial & Deception – Week 7Select one of the ‘Questions to Pon.docx
Denial & Deception – Week 7Select one of the ‘Questions to Pon.docxDenial & Deception – Week 7Select one of the ‘Questions to Pon.docx
Denial & Deception – Week 7Select one of the ‘Questions to Pon.docxruthannemcmullen
 
Denial-of-service attacks are a common method to bring down an organ.docx
Denial-of-service attacks are a common method to bring down an organ.docxDenial-of-service attacks are a common method to bring down an organ.docx
Denial-of-service attacks are a common method to bring down an organ.docxruthannemcmullen
 
Demonstration of core knowledgeThe following section demonstrate.docx
Demonstration of core knowledgeThe following section demonstrate.docxDemonstration of core knowledgeThe following section demonstrate.docx
Demonstration of core knowledgeThe following section demonstrate.docxruthannemcmullen
 
Describe at least five ways IT has helped change HR. What are the .docx
Describe at least five ways IT has helped change HR. What are the .docxDescribe at least five ways IT has helped change HR. What are the .docx
Describe at least five ways IT has helped change HR. What are the .docxruthannemcmullen
 
Dental offices, which most people consider environmentally benign .docx
Dental offices, which most people consider environmentally benign .docxDental offices, which most people consider environmentally benign .docx
Dental offices, which most people consider environmentally benign .docxruthannemcmullen
 
Democracies Around the WorldThe United States does not have a .docx
Democracies Around the WorldThe United States does not have a .docxDemocracies Around the WorldThe United States does not have a .docx
Democracies Around the WorldThe United States does not have a .docxruthannemcmullen
 
Deliverable Length  500-750 wordsOutline the major theories of .docx
Deliverable Length  500-750 wordsOutline the major theories of .docxDeliverable Length  500-750 wordsOutline the major theories of .docx
Deliverable Length  500-750 wordsOutline the major theories of .docxruthannemcmullen
 
Deliverable Length  A one-page letter to employeesLetter to E.docx
Deliverable Length  A one-page letter to employeesLetter to E.docxDeliverable Length  A one-page letter to employeesLetter to E.docx
Deliverable Length  A one-page letter to employeesLetter to E.docxruthannemcmullen
 
Deliverable Length  400 - 600 wordsSummative Discussion Boa.docx
Deliverable Length  400 - 600 wordsSummative Discussion Boa.docxDeliverable Length  400 - 600 wordsSummative Discussion Boa.docx
Deliverable Length  400 - 600 wordsSummative Discussion Boa.docxruthannemcmullen
 
Deliverable Length800 - 1000 wordsDetailsWeekly tasks or ass.docx
Deliverable Length800 - 1000 wordsDetailsWeekly tasks or ass.docxDeliverable Length800 - 1000 wordsDetailsWeekly tasks or ass.docx
Deliverable Length800 - 1000 wordsDetailsWeekly tasks or ass.docxruthannemcmullen
 
Deliverable Length  2-4 pagesConsider the facts of the follow.docx
Deliverable Length  2-4 pagesConsider the facts of the follow.docxDeliverable Length  2-4 pagesConsider the facts of the follow.docx
Deliverable Length  2-4 pagesConsider the facts of the follow.docxruthannemcmullen
 
Deliverable Length  5 slides (body of presentation), with in-depth .docx
Deliverable Length  5 slides (body of presentation), with in-depth .docxDeliverable Length  5 slides (body of presentation), with in-depth .docx
Deliverable Length  5 slides (body of presentation), with in-depth .docxruthannemcmullen
 
Deliverable Length800–1,000 words, including a completed table.docx
Deliverable Length800–1,000 words, including a completed table.docxDeliverable Length800–1,000 words, including a completed table.docx
Deliverable Length800–1,000 words, including a completed table.docxruthannemcmullen
 
Deliverable Length  1-2 pagesSociologists cite the weakening .docx
Deliverable Length  1-2 pagesSociologists cite the weakening .docxDeliverable Length  1-2 pagesSociologists cite the weakening .docx
Deliverable Length  1-2 pagesSociologists cite the weakening .docxruthannemcmullen
 

More from ruthannemcmullen (20)

Describe how an attacker could use a sniffer in conjunction with a T.docx
Describe how an attacker could use a sniffer in conjunction with a T.docxDescribe how an attacker could use a sniffer in conjunction with a T.docx
Describe how an attacker could use a sniffer in conjunction with a T.docx
 
Describe a specific workplace conflict situation involving the compe.docx
Describe a specific workplace conflict situation involving the compe.docxDescribe a specific workplace conflict situation involving the compe.docx
Describe a specific workplace conflict situation involving the compe.docx
 
Describe common biases in decision making.Explain the roles of emo.docx
Describe common biases in decision making.Explain the roles of emo.docxDescribe common biases in decision making.Explain the roles of emo.docx
Describe common biases in decision making.Explain the roles of emo.docx
 
Describe an example of a television program that you believe clearly.docx
Describe an example of a television program that you believe clearly.docxDescribe an example of a television program that you believe clearly.docx
Describe an example of a television program that you believe clearly.docx
 
Describe Abell’s three-dimensional business-definition model and exp.docx
Describe Abell’s three-dimensional business-definition model and exp.docxDescribe Abell’s three-dimensional business-definition model and exp.docx
Describe Abell’s three-dimensional business-definition model and exp.docx
 
Describe an example of a contract that you or someone you know enter.docx
Describe an example of a contract that you or someone you know enter.docxDescribe an example of a contract that you or someone you know enter.docx
Describe an example of a contract that you or someone you know enter.docx
 
Denial & Deception – Week 7Select one of the ‘Questions to Pon.docx
Denial & Deception – Week 7Select one of the ‘Questions to Pon.docxDenial & Deception – Week 7Select one of the ‘Questions to Pon.docx
Denial & Deception – Week 7Select one of the ‘Questions to Pon.docx
 
Denial-of-service attacks are a common method to bring down an organ.docx
Denial-of-service attacks are a common method to bring down an organ.docxDenial-of-service attacks are a common method to bring down an organ.docx
Denial-of-service attacks are a common method to bring down an organ.docx
 
Demonstration of core knowledgeThe following section demonstrate.docx
Demonstration of core knowledgeThe following section demonstrate.docxDemonstration of core knowledgeThe following section demonstrate.docx
Demonstration of core knowledgeThe following section demonstrate.docx
 
Describe at least five ways IT has helped change HR. What are the .docx
Describe at least five ways IT has helped change HR. What are the .docxDescribe at least five ways IT has helped change HR. What are the .docx
Describe at least five ways IT has helped change HR. What are the .docx
 
Dental offices, which most people consider environmentally benign .docx
Dental offices, which most people consider environmentally benign .docxDental offices, which most people consider environmentally benign .docx
Dental offices, which most people consider environmentally benign .docx
 
Democracies Around the WorldThe United States does not have a .docx
Democracies Around the WorldThe United States does not have a .docxDemocracies Around the WorldThe United States does not have a .docx
Democracies Around the WorldThe United States does not have a .docx
 
Deliverable Length  500-750 wordsOutline the major theories of .docx
Deliverable Length  500-750 wordsOutline the major theories of .docxDeliverable Length  500-750 wordsOutline the major theories of .docx
Deliverable Length  500-750 wordsOutline the major theories of .docx
 
Deliverable Length  A one-page letter to employeesLetter to E.docx
Deliverable Length  A one-page letter to employeesLetter to E.docxDeliverable Length  A one-page letter to employeesLetter to E.docx
Deliverable Length  A one-page letter to employeesLetter to E.docx
 
Deliverable Length  400 - 600 wordsSummative Discussion Boa.docx
Deliverable Length  400 - 600 wordsSummative Discussion Boa.docxDeliverable Length  400 - 600 wordsSummative Discussion Boa.docx
Deliverable Length  400 - 600 wordsSummative Discussion Boa.docx
 
Deliverable Length800 - 1000 wordsDetailsWeekly tasks or ass.docx
Deliverable Length800 - 1000 wordsDetailsWeekly tasks or ass.docxDeliverable Length800 - 1000 wordsDetailsWeekly tasks or ass.docx
Deliverable Length800 - 1000 wordsDetailsWeekly tasks or ass.docx
 
Deliverable Length  2-4 pagesConsider the facts of the follow.docx
Deliverable Length  2-4 pagesConsider the facts of the follow.docxDeliverable Length  2-4 pagesConsider the facts of the follow.docx
Deliverable Length  2-4 pagesConsider the facts of the follow.docx
 
Deliverable Length  5 slides (body of presentation), with in-depth .docx
Deliverable Length  5 slides (body of presentation), with in-depth .docxDeliverable Length  5 slides (body of presentation), with in-depth .docx
Deliverable Length  5 slides (body of presentation), with in-depth .docx
 
Deliverable Length800–1,000 words, including a completed table.docx
Deliverable Length800–1,000 words, including a completed table.docxDeliverable Length800–1,000 words, including a completed table.docx
Deliverable Length800–1,000 words, including a completed table.docx
 
Deliverable Length  1-2 pagesSociologists cite the weakening .docx
Deliverable Length  1-2 pagesSociologists cite the weakening .docxDeliverable Length  1-2 pagesSociologists cite the weakening .docx
Deliverable Length  1-2 pagesSociologists cite the weakening .docx
 

Recently uploaded

A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonJericReyAuditor
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxAnaBeatriceAblay2
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 

Recently uploaded (20)

A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lesson
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 

CSC139 Chapter 9 Lab Assignments (1) Classes and Obj.docx

  • 1. CSC139 Chapter 9 Lab Assignments (1) Classes and Objects Objectives In this lab assignment, students will learn: - How to design and define class - How to create object - How to define a tester program to test the object Goals
  • 2. In this lab assignment, students will demonstrate the abilities to: - Design and define class - Create object - Define a tester program to test the object Grading - Design and create a GUI (20 pts) - Design and define class (40 pts) - Define tester program (40 pts)
  • 3. Develop a " BankAccount " windows form project, which will allow user to - Enter amount of money to deposit, withdraw or move - Deposit money in checking or savings account. - Withdraw money from checking or savings account. - Move money between checking account and saving account. - View the new balance on the form after each transaction. Here is sample input/output: When start to run project, initial balances for both checking and saving accounts ($1000.00) should be displayed on the form.
  • 4. After deposit $500.00 to checking account. After move $800.00 from saving to checking account. If user attempts to withdraw $4000.00 from checking account at this moment, a MessageBox should be displayed with an error message. Project specifications -------- 1. This project should perform object-oriented programming. Add a class file "Account.vb" to define class "Account", rename "Form1.vb" file as "AccountTesterForm.vb" which will create account object and test the object’s attributes and behaviors.
  • 5. 2. This is the GUI for the bank. The amount of money need to be entered from the textbox, each button represents a type of transaction. The new balance will be displayed on the form after each transaction. Please use the same control names in order to use the tester program code below. balanceLabel amountTextBox moveStoCButton withdrawSavingButton depositSavingButton
  • 6. moveCtoSButton depositCheckingButton withdrawCheckingButton 3. Here is the definition of class Account, some codes are missing, you may copy the code to your project in Visual Studio and complete the missing code. Public Class Account Private savingBalance As Decimal 'instance variable for balance in saving account Private checkingBalance As Decimal 'instance variable for balance in checking account
  • 7. 'constructor which initialize balances in both accounts to 1000.00 Public Sub New() savingBalance = 1000.0 checkingBalance = 1000.0 End Sub 'property for savingBalance Public Property Saving() As Double Get
  • 8. Return savingBalance End Get Set(ByVal value As Double) If value < 0 Then savingBalance = 0 Else savingBalance = value End If End Set
  • 9. End Property 'property for checkingBalance Public Property Checking() As Double 'write your code here End Property 'define how to deposit money to checking account Public Sub depositChecking(ByVal amount As Decimal) 'write your code here End Sub
  • 10. 'define how to deposit money to saving account Public Sub depositSaving(ByVal amount As Decimal) 'write your code here End Sub 'define how to withdraw money from checking account Public Sub withdrawChecking(ByVal amount As Decimal) If amount > Checking Then Throw New ArgumentOutOfRangeException( "Withdrawal amount must be less than or equal to balance.")
  • 11. ElseIf amount <= 0D Then Throw New ArgumentOutOfRangeException( "Withrawal amount must be positive.") End If Checking -= amount End Sub 'define how to withdraw money from saving account Public Sub withdrawSaving(ByVal amount As Decimal) 'write your code here
  • 12. End Sub 'define how to move money from checking to saving account Public Sub moveMoneyCheckingtoSaving(ByVal amount As Double) 'write your code here End Sub 'define how to move money from saving to checking account Public Sub moveMoneySavingtoChecking(ByVal amount As Double) 'write your code here End Sub
  • 13. End Class 4. Here is the code for accountTesterForm.vb, some codes are missing, you may copy the code to your project in Visual Studio and complete the missing code ( The header of event handler methods can NOT be copied, they need to be created by double clicking the corresponding buttons ). Option Strict On Public Class AccountTesterForm Dim account As New Account() Private Sub AccountTesterForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
  • 14. MyBase.Load displayBalance() End Sub Private Sub DepositCheckingButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DepositCheckingButton.Click Try account.depositChecking(Convert.ToDecimal(AmountTextBox. Text)) displayBalance() Catch ex As ArgumentOutOfRangeException MessageBox.Show("Deposit amount must be positive.",
  • 15. "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try AmountTextBox.Clear() ' clear the inputTextBox AmountTextBox.Focus() End Sub Private Sub DepositSavingButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DepositSavingButton.Click 'write your code here
  • 16. End Sub Private Sub withdrawCheckingButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles withdrawCheckingButton.Click 'write your code here End Sub Private Sub withdrawSavingButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles withdrawSavingButton.Click 'write your code here
  • 17. End Sub Private Sub movectosButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles movectosButton.Click 'write your code here End Sub Private Sub moveStoCButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles moveStoCButton.Click 'write your code here
  • 18. End Sub Private Sub displayBalance() balanceLabel.Text = "Checking balance: " & String.Format("{0:C}", account.Checking) & vbCrLf & "Saving balance: " & String.Format("{0:C}", account.Saving) End Sub End Class