Module Code & Module Title:
CS4001NT Programming
Assessment Weightage & Type:
30% Individual Coursework
Year and Semester:
2022 Autumn
Student Name: Aayush Khatiwada.
London Met ID: 22072041
College ID:NP05CP4A220009
Assignment Due Date: 10th May 2023
Word Count: 13059
I confirm that I understand my coursework needs to be submitted online via MySecondTeacher
under the relevant module page before the deadline in order for my assignment to be accepted
and marked. I am fully aware that late submissions will be treated as non-submission and a
mark of zero will be awarded.
Table of contents
Contents
1 INTRODUCTION................................................................................................. 1
1.1 Java .................................................................................................................. 1
1.2 GUI ( Graphical User Interface) .................................................................. 2
1.3 Introduction to tools ................................................................................... 5
2 CLASS DIAGRAM .............................................................................................. 7
3 Pseudocode ..................................................................................................... 11
3.1 Introduction to Pseudocode..................................................................... 11
3.2 Pseudocode for BankGUI ......................................................................... 12
4 Method Description ............................................................................................. 53
4.1 Method to add Debit Card......................................................................... 53
4.2 Method to Withdraw Amount ................................................................... 55
4.3 Method to Display Debit Card .................................................................. 57
4.4 Method to Add CreditCard........................................................................ 57
4.5 Method for set Credit Limit....................................................................... 61
4.6 Method for Cancle Credit Card ................................................................ 62
4.7 Method for Display Credit Card ............................................................... 63
5 TESTING .......................................................................................................... 64
5.1 Test 1 .......................................................................................................... 64
5.2 Test 2 .......................................................................................................... 66
5.2.1 Add DebitCard ........................................................................................ 66
5.2.2 ADD CREDIT CARD ................................................................................ 68
5.2.3 Withdraw amount from Debit Card ....................................................... 70
5.2.4 Set the Credit Limit ................................................................................ 72
5.2.5 Cancel the Credit Card ........................................................................... 74
5.3 Testing 3 ........................................................................................................ 76
5.3.1 Debit Unique card Id .............................................................................. 76
5.3.2 Withdraw card id mismatch ................................................................... 78
5.3.3 Debit invalid card id ............................................................................... 80
5.3.4 Credit Unique Card ID ............................................................................ 82
5.3.5 Set Credit Limit Card ID mismatch ....................................................... 83
5.3.6 Cancel credit card id mismatch ............................................................ 85
5.3.7 Credit card id invalid .......................................................................... 86
6 Error Detection and Correction .......................................................................... 87
6.1 Syntax Error............................................................................................... 87
6.2 Symmetric Error ............................................................................................ 88
6.3 Logical Error .............................................................................................. 91
7 Conclusion ........................................................................................................... 95
8 References ........................................................................................................... 96
9 APPENDIX .......................................................................................................... 102
Table of Figures
Figure 1: Java and Swing Logo ............................................................................... 2
Figure 2: Hierarchy Classes of AWT ....................................................................... 3
Figure 3: Hierarchy of Swing Classes. ................................................................... 4
Figure 4: Class diagram of BankGUI ...................................................................... 8
Figure 5: Class Diagram Methods of BankGUI ...................................................... 9
Figure 6 : Blue J class diagram. ............................................................................ 10
Figure 7: Pseudocode image. ................................................................................ 11
Figure 8: Running program using command prompt. ......................................... 65
Figure 9: Evidence of Test 1 Successful. ............................................................. 65
Figure 10: Evidence of Add Debit Successful. .................................................... 67
Figure 11: Details after adding Debit Card ........................................................... 67
Figure 12: Credit Card added successfully. ......................................................... 69
Figure 13: Details after money withdrawn............................................................ 71
Figure 14 : Money withdrawn successfully. ......................................................... 71
Figure 15: Credit Card added successfully. ......................................................... 73
Figure 16: Details of Credit Card after credit limit set. ........................................ 73
Figure 17: Credit Card cancelled successfully. ................................................... 75
Figure 18: Debit card id must be unique(error). .................................................. 77
Figure 19: Withdraw card id does not match ....................................................... 79
Figure 20: Debit Card Negative integer error.(Invalid) ........................................ 81
Figure 21: Credit Card id unique( error). .............................................................. 83
Figure 22: Set Credit Card Id doesnot matched.( Error) ..................................... 84
Figure 23: Cancel credit card id not matched. (Error) ......................................... 85
Figure 24: Credit Card Id negative integer. (Invalid)............................................ 86
Figure 25: Syntax error detection. ........................................................................ 87
Figure 26: Syntax error correction. ....................................................................... 88
Figure 27 : Symmetric error detection. ................................................................. 88
Figure 28 : Exception of symmetric error. ............................................................ 89
Figure 29 : Symmetric error location in program. .............................................. 89
Figure 30: Symmetric error correction in program.............................................. 90
Figure 31 : Symmetric error correction. ............................................................... 90
Figure 32 : Exception solved(not found) symmetric ........................................... 91
Figure 33 : Debit Card logical error ...................................................................... 92
Figure 34 : Details after debit card added. ........................................................... 93
Figure 35: Error detection of logical error............................................................ 93
Figure 36 : Logical Error correction...................................................................... 94
Table of Tables
Table 1:Method to add Debit Card. ....................................................................... 55
Table 2: Method to Withdraw Amount. ................................................................. 56
Table 3: Method to Display Debit Card. ................................................................ 57
Table 4:Method to Add Credit Card. ..................................................................... 60
Table 5: Method for set Credit Limit. .................................................................... 62
Table 6: Method for Cancle Credit Card. .............................................................. 62
Table 7: Method for Display Credit Card. ............................................................. 63
Table 8: Compile and run using command prompt. ............................................ 64
Table 9: Test 2 Add DebitCard. ............................................................................. 66
Table 10: Testing of Add Credit Card. .................................................................. 68
Table 11: Testing of Withdraw amount from Debit Card ..................................... 70
Table 12: Testing of Set Credit Limit. ................................................................... 72
Table 13: Testing of Cancel Credit Card............................................................... 74
Table 14: Debit card unique test. .......................................................................... 76
Table 15: Withdraw card id not matched. ............................................................. 78
Table 16: Debit Card id Invalid. ............................................................................. 80
Table 17 : Credit card id unique test. .................................................................... 82
Table 18: Set credit limit card id test. ................................................................... 84
Table 19: Cancel credit card id test. ..................................................................... 85
Table 20: Credit card id negative test. .................................................................. 86
Acknowledgement
First of all, I would like to thank my Itahari international College. Without their support
and proper guidance this coursework wouldn’t have reach the end My deepest
appreciation to our Lecturer and Tutor Mr. Jeewan Dhamala sir for suggesting and
encouraging us to coordinate our project and further assisting us in completing the
project which helped me to learn much more about java. Secondly, I would like to
thanks our parents for supporting me not just during finishing this Coursework but also
during our whole studies in order to fulfil my dreams. I would like to express my
gratitude towards all the peoples who helped me to complete my project support and
suggestions. Their continuous encouragement and valuable comments are truly
appreciable.
CS4001NT Programming
1 INTRODUCTION
1.1 Java
Java is high level object oriented programming Java is high level object oriented
programming language which was developed by James Gosling at Sun Microsystems
which was released in year 1995. Java is fastest, secure and reliable and it is the
generous propose programming language which let the programmers/Developers
write once and run anywhere, in simplest form it means that the compiled java code
can be run on any platform that supports java. The code of java are generally compiled
to byte code which can be run on any Java Virtual Machine. Java name is originally
chosen from the coffee. Java is one of the most popular language in today world and
it is similar to C and C++.
There are many advantages and disadvantages in java:
The major advantages are Object-Oriented Programming, Built-in security, Platform
independent, Enterprise-level applications, Robust, Multi-Threaded etc.
Some disadvantages are Memory consumption, slower performance , cost etc.
(goelshubhangi3118, 2023)
Main features of java:
i. Object-oriented Programming Language.
ii. Automatic Memory Management.
iii. Platform Independent.
iv. Robust/ Reliable.
v. Simple and Secure.
vi. Write Once run anywhere.
Terminology in java:
i. Java Runtime Environment(JRE).
ii. Java Virtual Machine (JVM).
iii. Java Development Kit(JDK).
iv. Garbage collector.
v. Abstract Window Toolkit(AWT).
vi. Application Programming Interface(API).
AAYUSH KHATWADA 1|Page
CS4001NT Programming
1.2 GUI ( Graphical User Interface)
The GUI in java stands for graphical user interface. GUI is a system of communicating
with visual components .GUI plays an important role to build easy interfaces for Java
applications. It allows users to communicate with smart electronic devices through
graphical cursors, icons, buttons, lables etc. User can interact with smart devices the
items that sends information and symbolizes an action, and the object can alter the
shape, size and visibility when the user interacts. As compared to a text-based
command-line interface, a GUI is more user-friendly and easier for the users.
(Levy, 2023)
Figure 1: Java and Swing Logo
AAYUSH KHATWADA 2|Page
CS4001NT Programming
There are threes sets of APIs for graphics programming currently:
i. AWT(Abstract Windowing Toolkit) : AWT was introduced in 1195. It is a
collection of graphical user Interface components and other required services
for GUI in java. The majority of the AWT UI components should be swapped
out for the recent Swing UI components.
Some features are : Robust event-handling model, A group of native interface
components, Layout managers, Tools for graphics and imaging, such as
classes for shapes, colors , and fonts. (Nanyang Technological University,
2021)
Hierarchy of AWT Classes:
Figure 2: Hierarchy Classes of AWT
AAYUSH KHATWADA 3|Page
CS4001NT Programming
ii. Swing toolkit : Swing is a java Foundation classes (JFC) library and an
extension of the AWT which was created by Sun Microsystems in 1997 after
the release of JDK 1.1.
Some features of Swings are: It is huge and has great depth, Swing is 100%
portable because it is written in pure java, Swing has Lightweight components,
Highly customizable. (Nanyang Technological University, 2021)
Hierarchy of Swing Classes:
Figure 3: Hierarchy of Swing Classes.
iii. JavaFX. (Nanyang Technological University, 2021)
Note: In our course we have studied only about AWT and Swing Toolkit.
AAYUSH KHATWADA 4|Page
CS4001NT Programming
1.3 Introduction to tools
In this project I have used various tools to do my coursework successfully. The
tools that I have used during my coursework have their own specific purpose
and functions. For documentation, visualization, writing code and testing of
codes various tools are required. Beneath are the list of the tools that I have
used during my coursework.
• Ms Word
Ms Word is a word processing program developed by Microsoft in 1983.
It is the word processing program that is most frequently used. It is used
to generate papers, letters, reports, resumes, etc. of a professional
caliber and also enables you to edit or alter a new or existing document.
The Word document has a.docx extension. Although it is a part of the
Microsoft Office package, you may purchase it independently and use it
on either Windows or macOS. The most recent Word version is 2019.
(bhagiradhrayini25, 2021)
• BlueJ
BlueJ is an Integrated Development Environment (IDE) that allows user
to develop java programs simply and quickly. The editor for BlueJ has a
special scope highlighting functions that colors the background of each
code block to make it easier for user to scan the code visually more
quickly and helps in spotting errors easily. Objects can be inspected in
running program.
Some Features of BlueJ are:
➔ Portable.
➔ Mature.
➔ Easy to use. (BlueJ, 2023)
AAYUSH KHATWADA 5|Page
CS4001NT Programming
• Draw.io
Online diagram editor Draw.io was created using Google Drive. With the
help of draw.io user can generate UML diagrams, flowcharts, network
diagrams, entity relations, and many other types of diagrams. he fact that
draw.io keeps the data in Google Drive eliminates the need for a
separate third party, which is one of its benefits (EDUCBA, 2023)
• Vs code
VS code stands for Visual Studio code. In simple words, vs code is a
code editor which is completely free which helps the programmer to write
code, debugging code and corrects the code using the intelli-sense
method. It is easy to use and make programmer easier to develop code.
Some features of Visual code editor are: It supports almost every
programming language, web-support, allows commenting between
code, it support cross-platform. (Pedamkar, 2023)
AAYUSH KHATWADA 6|Page
CS4001NT Programming
2 CLASS DIAGRAM
Class diagram is static diagram that represent the static view of an application. It
depicts various kinds of objects that are present in the system as well as their
interactions. Various different aspects of the system are described, visualized,
documented using class diagram. The class diagram gives the high-level view of
classes, relationships, and functions to provide the summary of the software system.
Unified Modeling Language is used to design class diagrams (UML).
Merits of Class Diagrams:
• It offers a general application software for easier comprehension.
• It could serve as the object model for intricate systems.
• It reduces the maintenance time by giving a general picture of an applications
structure before coding.
Components of Class diagrams are divided into three parts:
• Upper Section: It consists of class name.
• Middle Section: It consists of attributes that describes the standard of the class.
• Lower Section: The methods and operations are in the lower part. (javaTPoint,
2023)
AAYUSH KHATWADA 7|Page
CS4001NT Programming
Figure 4: Class diagram of BankGUI
AAYUSH KHATWADA 8|Page
CS4001NT Programming
Figure 5: Class Diagram Methods of BankGUI
AAYUSH KHATWADA 9|Page
CS4001NT Programming
Figure 6 : Blue J class diagram.
AAYUSH KHATWADA 10 |
Page
CS4001NT Programming
3 Pseudocode
3.1 Introduction to Pseudocode
Pseudocode is described as a technique for expressing programming
code .The term pseudo code refers to a false code or a representation
of code that even a layperson with basic programming understanding
can understand. It is a method that enables the programmer to depict
how an algorithm is implemented in their program. It is the fabricated
representation of an algorithm, to put it simply. Pseudo codes are
frequently used to depict algorithms because the may be understood by
programmers with any level of programming experience.
Figure 7: Pseudocode image.
AAYUSH KHATWADA 11 |
Page
CS4001NT Programming
3.2 Pseudocode for BankGUI
Pseudocode of BankGUI
FUNCTION BankGUI()
CALL frame()
CALL menu()
FUNCTION Frame()
CREATE JFrame object with title “BankGUI”
SET size 550x500 in x-axis and y-axis and set layout to null
SET background color to white and location relative to null
SET default close operation to exit on close and resizable to false
END FUNCTION
FUNCTION menu()
CREATE JMenuBar object menu
SET “menu” to Frame f
CREATE JMenu object m1 with title “File”
ADD “m1” to menu
CREATE JMenuItem object “Item1”with title”EXIT”
SET Accelerator to Item1
REGISTER ActionListener to Item1
FUNCTION actionPerformed
AAYUSH KHATWADA 12 |
Page
CS4001NT Programming
exit from the frame
END FUNCTION
ADD “Item1” to m1
CREATE JMenu object m2 with title “About”
ADD “m2” to menu
CREATE JMenuItem object “Item2” with title “Version”
SET Accelerator to Item2
REGISTER ActionListener to Item2
FUNCTION actionPerformed
DISPLAY Version details
END FUNCTION
ADD “Item2” to m2
CREATE JMenuItem object “Item3”with title “Developer”
SET Accelerator to Item3
REGISTER ActionListener to Item3
FUNCTION actionPerformed
DISPLAY Developer information
END FUNCTION
ADD “Item3” to m2
END FUNCTION
AAYUSH KHATWADA 13 |
Page
CS4001NT Programming
FUNCTION mainPanel()
CREATE JPanel object with setBounds 0,0,700,700 and layout
null.
SET background color to white
CREATE JLabel object bankGui with text “Bank GUI”
SET Bounds of bankGui 170,20,200,80 and font to Avallon
and size 40.
ADD bankGui to mainPanel
CREATE JLabel object debitCard with text “Click here to enter
DebitCard” .
SET font Arial size 20 and setBounds of debitCard 30,250,300,30
ADD debitCard to mainPanel
CREATE JLabel object creditCard with text “Click here to enter
CreditCard”
SET font Arial size 20 and setBounds of creditCard
30,250,300,30.
ADD creditCard to mainPanel
CREATE JButton object addDebitBtn with title “Add Debit”
SET Bounds of addDebitBtn to 380,150,140,40
REGISTER ActionListener to addDebitBtn
AAYUSH KHATWADA 14 |
Page
CS4001NT Programming
FUNCTION actionPerformed
UPDATE frame f visibility to false
UPDATE frame debitF visibility to true
UPDATE panel debitPanel visibility to true
END FUNCTION
ADD addDebitBtn to mainPanel
CREATE JButton object addCreditBtn with title “Add Credit”
SET Bounds of addDebitBtn to 380,250,140,40
REGISTER ActionListener to addCreditBtn
FUNCTION actionPerformed
UPDATE frame f visibility to false
UPDATE frame creditF visibility to true
UPDATE panel creditPanel visibility to true
END FUNCTION
ADD addCreditBtn to mainPanel
CREATE JButton object exitButton with title “Exit”
SET Bounds of addDebitBtn to 200,350,100,30
REGISTER ActionListener to exitButton
FUNCTION actionPerformed
Exit from the system
END FUNCTION
AAYUSH KHATWADA 15 |
Page
CS4001NT Programming
ADD exitButton to mainPanel
ADD mainPanel to frame f
END FUNCTION
FUNCTION debitPanel()
CREATE JFrame object debitF with title “Debit Card”
SET size of debitF 800x700 and background color DARK GRAY
SET layout to null, location Relative to null
SET default close operation to exit on close and resizable to false
CREATE JPanel object debitPanel with setBounds to
45,50,700,300 and layout to null
SET border to debitPanel with Title “Debit Card” and background
color to gray
ADD debitPanel to frame debitF
CREATE JLabel object client with text “Client Name”
SET bounds of client to 20,40,80,30
ADD client to debitPanel
CREATE JLabel object account with text “Bank Account”
SET bounds of account to 20,80,100,30
ADD account to debitPanel
AAYUSH KHATWADA 16 |
Page
CS4001NT Programming
CREATE JLabel object card with text “Card ID”
SET bounds of card to 20,120,90,30
ADD card to debitPanel
CREATE JLabel object bank with text “Issuer Bank”
SET bounds of bank to 20,160,90,30
ADD bank to debitPanel
CREATE JLabel object amount with text “Balance Amount”
SET bounds of amount to 20,200,120,30
ADD amount to debitPanel
CREATE JLabel object pin with text “PIN Number”
SET bounds of pin to 20,240,90,30
ADD pin to debitPanel
CREATE JTextField object tfClient
SET bounds of tfClient to 120,35,200,30
ADD tfClient to debitPanel
CREATE JTextField object tfBankAc
SET bounds of tfBankAc to 120,80,200,30
ADD tfBankAc to debitPanel
AAYUSH KHATWADA 17 |
Page
CS4001NT Programming
CREATE JTextField object tfCard
SET bounds of tfCard to 120,120,200,30
ADD tfCard to debitPanel
CREATE JTextField object tfIssuer
SET bounds of tfIssuer to 120,160,200,30
ADD tfIssuer to debitPanel
CREATE JTextField object tfAmt
SET bounds of tfAmt to 120,200,200,30
ADD tfAmt to debitPanel
CREATE JTextField object tfPinNumber
SET bounds of tfPinNumber to 120,240,200,30
ADD tfPinNumber to debitPanel
CREATE JButton object back with text “Back”
SET setBounds of back to 40,600,100,30
REGISTER ActionListener to back
FUNCTION actionperformed
UPDATE frame debitF visibility to false
UPDATE frame f visibility to true
AAYUSH KHATWADA 18 |
Page
CS4001NT Programming
END FUNCTION
ADD back to debitF
CREATE JButton object clear with text “Clear”
SET setBounds of clear to 580,250,100,30
REGISTER ActionListener to clear
FUNCTION actionperformed
CALL METHOD clearDebit()
END FUNCTION
ADD clear to debitPanel
CREATE JButton object display with text “Display”
SET setBounds of display to 680,600,100,30
REGISTER ActionListener to display
FUNCTION actionperformed
CALL METHOD displayDebitCard()
END FUNCTION
ADD display to debitF
CREATE JButton object addDebit with text “Add Debit”
SET setBounds of addDebit to 400,130,150,30
REGISTER ActionListener to addDebit
FUNCTION actionperformed
AAYUSH KHATWADA 19 |
Page
CS4001NT Programming
CALL METHOD addDebitCard()
UPDATE withdrawPanel visibility to true
END FUNCTION
ADD addDebit to debitPanel
CREATE JLabel object with text “Debit Card”
SET font Avallon size 40 and background color WHITE
ADD debitTitle to debitPanel
SET Frame f visibility to true
END FUNCTION
FUNCTION withdrawPanel()
CREATE JPanel object withdrawPanel with setLayout null and
background color gray
SET bounds of withdrawPanel 45,360,700,230 and border with
title “Withdraw Amount”
SET withdrawPanel visibility to true
ADD withdrawPanel to debitF
CREATE JLabel object withdrawalAmount with Text “Withdrawal
Amount”
SET bounds of withdrawalAmount to 30,20,150,30
ADD withdrawalAmount to withdrawPanel
CREATE JLabel object withdrawDate with text“Date of Withdraw”
AAYUSH KHATWADA 20 |
Page
CS4001NT Programming
SET bounds of withdrawDate to 30,70,120,30
ADD withdrawalAmount to withdrawPanel
CREATE JLabel object pin with text “PIN Number ”
SET bounds of pin to 30,130,120,30
ADD pin to withdrawPanel
CREATE JLabel object card with text “Card ID”
SET bounds of withdrawDate to 30,180,120,30
ADD card to withdrawPanel
CREATE JTextField object tfCardID
SET bounds of tfCardID to 180,180,120,30
ADD tfCardID to withdrawPanel
CREATE JTextField object tfWithdrawalAmt
SET bounds of tfWithdrawalAmt to 180,20,120,30
ADD tfWithdrawalAmt to withdrawPanel
CREATE JTextField object tfPin
SET bounds of tfPin to 180,130,120,30
ADD tfPin to withdrawPanel
AAYUSH KHATWADA 21 |
Page
CS4001NT Programming
CREATE JButton object withdraw with text “Withdraw”
SET bounds of withdraw to 480,70,170,30
REGISTER actionListner to withdraw
FUNCTION actionPerformed
CALL METHOD withdrawDebit()
END FUNCTION
ADD withdraw to withdrawPanel
INITAILIZE an Array of String named Year for combobox
CREATE Array of String named Month for combobox
SET value of Month to { "Month", "Jan", "Feb", "Mar", "Apr",
"May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
INITAILIZE Array of String named Day for combobox
CREATE JComboBox object withdrawalBoxYear
CREATE JComboBox object withdrawalBoxMonth
CREATE JComboBox object withdrawalBoxDay
SET withdrawalBoxYear bounds to 180,70,70,30
SET withdrawalBoxYear visibility to true
ADD withdrawalBoxYear to withdrawPanel
SET withdrawalBoxMonth bounds to 250,70,70,30
SET withdrawalBoxMonth visibility to true
ADD withdrawalBoxMonth to withdrawPanel
SET withdrawalBoxDay bounds to 320,70,50,30
AAYUSH KHATWADA 22 |
Page
CS4001NT Programming
SET withdrawalBoxDay visibility to true
ADD withdrawalBoxDay to withdrawPanel
CREATE JButton object clear with text “Clear”
SET bounds of clear to 580,190,100,30
REGISTER ActionListener to clear
FUNCTION actionPerformed
CALL METHOD clearWithdraw()
END FUNCTION
ADD clear to withdrawPanel
SET mainPanel visibility to true
SET withdrawPanel to false
END FUNCTION
FUNCTION clearDebit()
SET text of JTextfields tfClient to “ ”
SET text of JTextfields tfIssuer to “ ”
SET text of JTextfields tfCard to “ ”
SET text of JTextfields tfBankAc to “ ”
SET text of JTextfields tfPinNumber to “ ”
SET text of JTextfields tfAmt to “ ”
END FUNCTION
AAYUSH KHATWADA 23 |
Page
CS4001NT Programming
FUNCTION clearWithdraw()
SET text of JTextfields tfWithdrawalAmt to “ ”
SET text of JTextfields tfPin to “ ”
SET text of JTextfields tfCardID to “ ”
SET index of JComboBox withdrawalBoxYear to 0
SET index of JComboBox withdrawalBoxMonth to 0
SET index of JComboBox withdrawalBoxDay to 0
END FUNCTION
FUNCTION creditPanel()
CREATE JFrame object creditF with title “Credit Card” with size
800x700 and set layout to null
SET default close operation to exit on close and resizable to false
SET background color to DARK_GRAY and set location relative
to null .
CREATE JPanel object creditPanel and set layout to null
SET bounds of creditPanel to 45,50,700,300
SET border to debitPanel with Title “Credit Card” and background
color to gray
ADD creditPanel to frame creditF
CREATE JLabel object client witht text “Client Name”
SET bounds of client to 20,40,80,30
ADD client to creditPanel
AAYUSH KHATWADA 24 |
Page
CS4001NT Programming
CREATE JLabel object account witht text “Bank Account”
SET bounds of account to 20,80,100,30
ADD account to creditPanel
CREATE JLabel object card witht text “Card ID”
SET bounds of card to 20,120,90,30
ADD card to creditPanel
CREATE JLabel object bank witht text “Balance Amount”
SET bounds of bank to 20,160,120,30
ADD bank to creditPanel
CREATE JLabel object amount witht text “Balance Amount”
SET bounds of amount to 20,200,120,30
ADD amount to creditPanel
CREATE JLabel object cvc witht text “CVC Number”
SET bounds of cvc to 400,70,80,30
ADD cvc to creditPanel
CREATE JLabel object interesRate witht text “Interest Rate”
SET bounds of client to 400,120,100,30
ADD interestRate to creditPanel
CREATE JLabel object expirationDate witht text “Expiration Date”
SET bounds of expirationDate to 400,170,100,30
ADD expirationDate to creditPanel
INITIALIZE Array of String named Year for combobox
FOR
AAYUSH KHATWADA 25 |
Page
CS4001NT Programming
INITIALIZE Array of String named Month for combobox
SET value of Month to { "Month", "Jan", "Feb", "Mar", "Apr",
"May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
INITIALIZE Array of String named Day for combobox
FOR
CREATE JComboBox object expirationBoxYear
CREATE JComboBox object expirationBoxMonth
CREATE JComboBox object expirationBoxDay
SET expirationBoxYear bounds to 500,170,70,30
SET expirationBoxYear visibility to true
ADD expirationBoxYear to creditPanel
SET expirationBoxMonth bounds to 570,170,70,30
SET expirationBoxMonth visibility to true
ADD expirationBoxMonth to creditPanel
SET expirationBoxDay bounds to 640,170,50,30
SET expirationBoxDay visibility to true
ADD expirationBoxDay to creditPanel
CREATE JTextField for tfCreClient
SET bound of tfCreClient to 120,35,200,30
ADD tfCreClient to creditPanel
CREATE JTextField for tfCreBankAcc
SET bound of tfCreBankAcc to 120,80,200,30
ADD tfCreBankAcc to creditPanel
AAYUSH KHATWADA 26 |
Page
CS4001NT Programming
CREATE JTextField for tfCreCardId
SET bound of tfCreCardId to 120,120,200,30
ADD tfCreCardId to creditPanel
CREATE JTextField for tfCredIssuer
SET bound of tfCredIssuer to 120,160,200,30
ADD tfCredIssuer to creditPanel
CREATE JTextField for tfCreBalanceAmt
SET bound of tfCreBalanceAmt to 120,200,200,30
ADD tfCreBalanceAmt to creditPanel
CREATE JTextField for tfCVC
SET bound of tfCVC to 480,70,200,30
ADD tfCVC to creditPanel
CREATE JTextField for tfInterestRate
SET bound of tfInterestRate to 480,120,200,30
ADD tfInterestRate to creditPanel
CREATE JButton object backCredit with text “Back”
SET bounds of backCredit to 60,600,100,30
REGISTER ActionListner to backCredit
FUNCTION actionperformed
SET creditF visibility to false
SET f visibility to true
END FUNCTION
ADD backCredit to creditF
AAYUSH KHATWADA 27 |
Page
CS4001NT Programming
CREATE JButton object clearCredit with text “Clear”
SET bounds of clearCredit to 160,250,100,30
REGISTER ActionListner to clearCredit
FUNCTION actionperformed
CALL METHOD clearCre()
END FUNCTION
ADD clearCredit to creditPanel
CREATE JButton object display with text “Display”
SET bounds of display to 650,600,100,30
REGISTER ActionListner to display
FUNCTION actionperformed
CALL METHOD displayCreditCard()
END FUNCTION
ADD display to creditF
CREATE JButton object addCredit with text “Add Credit”
SET bounds of addCredit to 350,250,120,30
REGISTER ActionListner to addCredit
FUNCTION actionperformed
CALL METHOD addCreditCard()
END FUNCTION
ADD addCredit to creditPanel
CREATE JLabel object creditTitle and setText “Credit Card”
SET Font to Avallon and size 40
AAYUSH KHATWADA 28 |
Page
CS4001NT Programming
SET background color to WHITE
SET bounds of creditTitle to 300,05,250,40
ADD creditTitle to frame creditF
END FUNCTION
FUNCTION setCreditPanel()
CREATE JPanel object setCreditPanel
SET bounds of setCreditPanel 50,380,370,200 and layout to null
SET setCreditPanel setBorder with title “Set Credit Amount”
SET background color to gray and visibility to true
ADD setCreditPanel to creditF
CREATE JLabel object card with text “Card Id”
SET bounds of card 30,110,150,30
ADD card to setCreditPanel
CREATE JLabel object creditLimit with text “Credit Limit”
SET bounds of creditLimit 30,20,150,30
ADD creditLimit to setCreditPanel
CREATE JLabel object grace with text “Grace Period”
SET bounds of grace 30,70,100,30
ADD grace to setCreditPanel
AAYUSH KHATWADA 29 |
Page
CS4001NT Programming
CREATE JTextField object tfsetCreditCard
SET bounds of tfsetCreditCard 130,110,200,30
ADD tfsetCreditCard to setCreditPanel
CREATE JTextField object tfGrace
SET bounds of tfGrace 130,70,200,30
ADD tfGrace to setCreditPanel
CREATE JButton object setCredit
SET bounds of setCredit 150,160,180,30
REGISTER ActionListener to setCredit
FUNCTION actionPerformed
CALL METHOD setCredit()
END FUNCTION
ADD setCredit to setCreditPanel
END FUNCTION
AAYUSH KHATWADA 30 |
Page
CS4001NT Programming
FUNCTION cancelCreditPanel()
CREATE JPanel object cancelCreditPanel
SET bounds of cancelCreditPanel 440,380,300,200 and layout to
null
SET setCreditPanel setBorder with title “Cancle Credit Amount”
SET background color to gray and visibility to true
ADD cancelCreditPanel to creditF
CREATE JLabel object card with text “Card ID”
SET bounds of card 20,60,100,20
ADD card to cancleCreditPanel
CREATE JTextField object tfCancelCard
SET bounds of tfCancelCard 80,60,200,30
ADD tfCancelCard to cancelCreditPanel
CREATE JButton object cancelCreditBtn
SET bounds of cancelCreditBtn 100,150,120,30
REGISTER ActionListener to cancelCreditBtn
FUNCTION actionPerformed
CALL METHOD cancelCreditCard()
END FUNCTION
ADD cancelCredit to cancelCreditPanel
END FUNCTION
AAYUSH KHATWADA 31 |
Page
CS4001NT Programming
FUNCTION clearCre()
SET text of JTextfield tfCreClient to “ ”
SET text of JTextfield tfCreBankAcc to “ ”
SET text of JTextfield tfCreBalanceAmt to “ ”
SET text of JTextfield tfCreCardId to “ ”
SET text of JTextfield tfCredIssuer to “ ”
SET text of JTextfield tfGrace to “ ”
SET text of JTextfield tfCVC to “ ”
SET text of JTextfield tfInterestRate to “ ”
SET text of JTextfield tfCreditLimit to “ ”
SET text of JTextfield tfsetCreditCard to “ ”
SET index of JComboBox expirationBoxYear to 0
SET index of JComboBox expirationBoxMonth to 0
SET index of JComboBox expirationBoxDay to 0
END FUNCTION
FUNCTION addDebitCard()
INITIALIZE client = getClientName()
INITIALIZE bank = getIssuerName()
INITIALIZE account = getBankAccount()
IF client equals “ ” OR bank isEmpty OR account isEmpty
THEN
DISPLAY Please fill the form
AAYUSH KHATWADA 32 |
Page
CS4001NT Programming
RETURN
INITIALIZE amount equals to getBalanceAmount()
INITIALIZE pin equals to getPinNUmber()
INITIALIZE card equals to getCardID()
IF amount less than equals to zero THEN
UPDATE amount equals to INVALID
END IF
IF pin amount less than equals to zero THEN
UPDATE pin equals to INVALID
END IF
IF card amount less than equals to zero THEN
UPDATE card equals to INVALID
END IF
IF amount is Equals to INVALID THEN
DISPLAY “Please enter appropriate Balance Amount”
RETURN
END IF
IF pin is Equals to INVALID THEN
DISPLAY “Please enter valid Pin Number”
RETURN
END IF
IF card is Equals to INVALID THEN
DISPLAY “Please enter valid card Id”
AAYUSH KHATWADA 33 |
Page
CS4001NT Programming
RETURN
END IF
IF amount Equals INVALID AND pin Equals INVALID AND card
Equals INVALID THEN
DISPLAY “Please enter appropriate Balance Amount”
RETURN
END IF
IF isUnique THEN
UPDATE arraylist bankgui TO (new DebitCard(amount ,
card,account, bank, client, pin)
DISPLAY “Debit Successfully added”
END IF
END FUNCTION
FUNCTION getClientName()
RETURN tfClient.getText().trim()
END FUNCTION
FUNCTION getBankAccount()
RETURN tfBankAc.getText().trim()
END FUNCTION
FUNCTION getBIssuerName()
AAYUSH KHATWADA 34 |
Page
CS4001NT Programming
RETURN tfIssuerName.getText().trim()
END FUNCTION
FUNCTION getBalanceAmount()
amount equals to tfAmt.getText().trim()
amountBank equals to INVALID
IF amount isEmpty THEN
UPDATE amountBank equals to EMPTY
RETURN amountBank
TRY
amountBank equals to Integer.parseInt(amount)
CATCH NumberFormatException e
RETURN amountBank
END FUNCTION
FUNCTION getCardID()
cardText equals to tfCard.getText().trim()
card equals to INVALID
IF cardText isEmpty THEN
UPDATE card equals to EMPTY
RETURN card
END IF
TRY
AAYUSH KHATWADA 35 |
Page
CS4001NT Programming
card equals to Integer.parseInt(cardText)
CATCH NumberFormatException e
RETURN card
END FUNCTION
FUNCTION getCardID()
cardText equals to tfCard.getText().trim()
card equals to INVALID
IF cardText isEmpty THEN
UPDATE card equals to EMPTY
RETURN card
END IF
TRY
card = Integer.parseInt(cardText)
CATCH (NumberFormatException e)
RETURN card
END FUNCTION
FUNCTION getPinNUmber()
pinText equals to tfPinNumber.getText().trim()
pin equals to INVALID
IF pinText isEmpty THEN
UPDATE pin equals to EMPTY
RETURN pin
END IF
AAYUSH KHATWADA 36 |
Page
CS4001NT Programming
TRY
pin equals to Integer.parseInt(pinText)
CATCH NumberFormatException e
RETURN pin
END FUNCTION
FUNCTION isUnique(int card)
Unique equals to true
FOR each object stored in Arraylist bankgui
IF that object getCardId() equals to card
IF that object is instanceof DebitCard
DISPLAY "Card ID must be unique"
UPDATE unique equals to false
BREAK LOOP
END IF
END LOOP
RETURN unique
END FUNCTION
FUNCTION withdrawDebit()
INITIALIZE withdrawDate equals to getwithdrawDate()
INITIALIZE pin equals to getPin()
INITIALIZE Card equals to getWithdrawCardID()
IF withdrawAmt is Equals to INVALID THEN
AAYUSH KHATWADA 37 |
Page
CS4001NT Programming
DISPLAY “Please enter withdraw amount”
RETURN
IF pinNumber is Equals to INVALID THEN
DISPLAY “Please enter Pin Number”
RETURN
IF Card is Equals to INVALID THEN
DISPLAY “Please enter card ID”
RETURN
SET isPresent = false
FOR each object stored in Arraylist bankgui
IF that object is instanceof DebitCard
CHANGE reference of that object to DebitCard
IF valid card id is entered
UPDATE withdraw (withdrawAmt,
pinNumber,withdrawDate)
SET withdrawPanel visibility to true
UPDATE isPresent to true
BREAK LOOP
END IF
END LOOP
IF isPresent Equals to true
DISPLAY “ Please See terminal for the message”
END IF
AAYUSH KHATWADA 38 |
Page
CS4001NT Programming
ELSE
DISPLAY “ Incorrect cardId ”
RETURN
END FUNCTION
AAYUSH KHATWADA 39 |
Page
CS4001NT Programming
FUNCTION getWithdrawDate()
RETURN(withdrawalBoxYear.getSelectedItem()+"
"+withdrawalBoxMonth.getSelectedItem()+" "+
withdrawalBoxDay.getSelectedItem())
END FUNCTION
FUNCTION getPin()
pinNumberText equals to tfPin.getText().trim()
int pinNumber equals to INVALID
IF pinNumberText isEmpty()
UPDATE pinNumber equals to EMPTY
END IF
TRY
pinNumber equals to Integer.parseInt(pinNumberText)
CATCH NumberFormatException p
IF pinNumber less than equals to 0
UPDATE pinNumber equals to INVALID
RETURN pinNumber
END FUNCTION
FUNCTION getWithdrawAmt()
withdrawText equals to tfWithdrawalAmt.getText().trim()
withdrawAmt equals to INVALID
IF withdrawAmt isEmpty()
UPDATE withdrawAmt equals to EMPTY
AAYUSH KHATWADA 40 |
Page
CS4001NT Programming
TRY
withdrawAmt equals to Integer.parseInt(withdrawText)
CATCH NumberFormatException w
IF withdrawAmt less than equals to 0
UPDATE withdrawAmt equals to INVALID
RETURN withdrawAmt
END FUNCTION
FUNCTION getWithdrawCardID()
cardIDText equals to tfCardID.getText().trim()
Card equals to INVALID
IF cardText isEmpty()
UPDATE card equals to INVALID
END IF
TRY
Card equals to Integer.parseInt(cardIDText)
CATCH (NumberFormatException c)
IF less than equals to
UPDATE Card equals to INVALID
RETURN Card
END FUNCTION
FUNCTION displayDebitCard()
present equals to false
AAYUSH KHATWADA 41 |
Page
CS4001NT Programming
FOR each object stored in Arraylist bankgui
IF that object is instanceof DebitCard THEN
CALL debit.display()
DISPLAY "Details Displayed Done Successfully"
UPDATE present equals to true
ELSE
DISPLAY "Details not an DebitCard"
RETURN
IF present is Equals to false
DISPLAY "Please add Debit Information First"
RETURN
END IF
END FUNCTION
FUNCTION addCreditCard()
INITIALIZE creClientName equals to getCreClient()
INITIALIZE creBankAcc equals to getCreBankAcc()
INITIALIZE expirationDate equals to getExpirationDate()
IF creClientName isEmpty OR creBankAcc isEmpty() OR
creIssuer isEmpty
DISPLAY "Please fill all the boxes"
RETURN
INITIALIZE creCard equals to getCreCardId()
INITIALIZE cvc equals to getCvcNum()
AAYUSH KHATWADA 42 |
Page
CS4001NT Programming
INITIALIZE interestRate equals to getInterestRate()
INITIALIZE creBalanceAmount equals to getCreBalanceAmt()
IF creCard less than equals to 0
UPDATE creCard equals to INVALID
END IF
IF interestRate less than equals to 0
UPDATE interestRate equals to INVALID
END IF
IF creBalanceAmount less than equals to 0
UPDATE creBalanceAmount equals to INVALID
END IF
IF creCard is Equals to INVALID THEN
DISPLAY "Please enter positive number in card Id"
RETURN
END IF
IF cvc is Equals to INVALID THEN
DISPLAY "Please enter positive number in CVC Number"
RETURN
END IF
IF interestRate is Equals to INVALID THEN
DISPLAY "Please enter positive and valid number in
Interest Rate"
RETURN
END IF
AAYUSH KHATWADA 43 |
Page
CS4001NT Programming
IF creBalanceAmount is Equals to INVALID THEN
DISPLAY "Please enter positive number in Balance
Amount"
RETURN
END IF
IF creCard Equals INVALID AND cvc Equals INVALID AND
interestRate Equals INVALID AND creBalanceAmount
Equals INVALID
DISPLAY "invalid balanceamount, CVC number,Interest
Rate or card id"
RETURN
END IF
IF creditIsUnique(creCard) Equals to true THEN
UPDATE bankgui TO add(new
CreditCard (creBalanceAmount, creCard,
creBankAcc, creIssuer, creClientName, cvc,
interestRate, expirationDate)
DISPLAY "Credit Added Successfully for Mr/Mrs
creClientName THANK YOU”
END IF
END FUNCTION
FUNCTION getExpirationDate()
RETURN (expirationBoxYear.getSelectedItem()+"
"+expirationBoxMonth.getSelectedItem()+" "+
expirationBoxDay.getSelectedItem())
END FUNCTION
AAYUSH KHATWADA 44 |
Page
CS4001NT Programming
FUNCTION getCreClient()
RETURN tfCreClient.getText().trim()
END FUNCTION
FUNCTION getCreIssuer()
RETURN tfCreIssuer.getText().trim()
END FUNCTION
FUNCTION getCreBankAcc()
RETURN tfCreBankAcc.getText().trim()
END FUNCTION
FUNCTION getCreCardId()
cardTxt equals to tfCreCardId.getText().trim()
cardId equals to INVALID
IF cardTxt isEmpty()
UPDATE cardId equals to EMPTY
RETURN cardId
END IF
TRY
cardId equals to Integer.parseInt(cardTxt)
CATCH (Exception c)
RETURN cardId
END FUNCTION
FUNCTION getInterestRate()
rateTxt equals to tfInterestRate.getText().trim()
AAYUSH KHATWADA 45 |
Page
CS4001NT Programming
interest equals to INVALID
IF rateTxt isEmpty()
UPDATE interest equals to EMPTY
RETURN interest
END IF
TRY
Interest equals to Double.parseDouble(rateTxt)
CATCH (Exception i)
RETURN interest
END FUNCTION
FUNCTION getCvcNum()
cvcTxt equals to tfCVC.getText().trim()
cvc equals to INVALID
IF cvcTxt isEmpty()
UPDATE cvc equals to EMPTY
END IF
TRY
Cvc equals to Integer.parseInt(cvcTxt)
CATCH (Exception c)
RETURN cvc
END FUNCTION
FUNCTION getCreBalanceAmt()
balanceTxt equals to tfCreBalanceAmt.getText().trim()
AAYUSH KHATWADA 46 |
Page
CS4001NT Programming
creBalanceAmt equals to INVALID
IF balanceTxt isEmpty()
UPDATE creBalanceAmt equals to EMPTY
END IF
TRY
creBalanceAmt equals to Integer.parseInt(cvcTxt)
CATCH (Exception amt)
RETURN creBalanceAmt
END FUNCTION
FUNCTION creditIsUnique(int creCard)
cardUnique equals to true
FOR each object stored in Arraylist bankgui
IF that object getCardId is Equal to creCard
IF that object is instanceof CreditCard
DISPLAY "Card ID must be unique"
UPDATE cardUnique equals to false
BREAK LOOP
END IF
END IF
END LOOP
RETURN cardUnique
END FUNCTION
AAYUSH KHATWADA 47 |
Page
CS4001NT Programming
FUNCTION setCredit()
INITIALIZE cardID equals to getCreLimitCardId();
INITIALIZE gracePeriod equals to getGracePeriod()
INITIALIZE creditLimit equals to getCreditLimit()
IF cardID Equals INVALID OR gracePeriod Equals INVALID OR
creditLimit Equals INVALID
THEN
DISPLAY "Please Enter valid CardID,Grace Period and
CreditLimit"
RETURN
SET isSet equals to false
FOR each object stored in Arraylist bankgui
IF that object is instanceof CreditCard
CHANGE reference of that object to CreditCard
IF valid card id is entered
UPDATE setCreditLimit (creditLimit,
gracePeriod)
UPDATE isSet equals to true
BREAK LOOP
END IF
END LOOP
IF isSet Equals to true
AAYUSH KHATWADA 48 |
Page
CS4001NT Programming
DISPLAY "Credit Limit set Successfully for Card ID,
Please See terminal for the message"
END IF
ELSE
DISPLAY “ Incorrect cardId ”
RETURN
END FUNCTION
FUNCTION getCreditLimit()
creditLimitTxt equals to tfCreditLimit.getText().trim()
creditLimit equals to INVALID
IF creditLimitTxt isEmpty()
UPDATE creditLimit equals to EMPTY
END IF
TRY
creditLimit equals to Integer.parseInt(creditLimitTxt)
CATCH (Exception l)
IF creditLimit less than equals to 0
UPDATE creditLimit equals to INVALID
END IF
RETURN creditLimit
END FUNCTION
FUNCTION getGracePeriod()
graceTxt equals to tfGrace.getText().trim();
AAYUSH KHATWADA 49 |
Page
CS4001NT Programming
gracePeriod equals to INVALID
IF graceTxt isEmpty()
UPDATE gracePeriod equals to EMPTY
END IF
TRY
gracePeriod equals to Integer.parseInt(graceTxt)
CATCH (Exception g)
IF gracePeriod less than equals to 0
UPDATE gracePeriod equals to INVALID
END IF
RETURN gracePeriod
END FUNCTION
FUNCTION getCreLimitCardId()
cardIdTxt equals to tfsetCreditCard.getText().trim()
cardID equals to INVALID
IF cardIdTxt isEmpty()
UPDATE cardID equals to EMPTY
END IF
TRY
cardID equals to Integer.parseInt(cardIDTxt)
CATCH (Exception set)
IF cardID less than equals to 0
UPDATE cardID equals to INVALID
AAYUSH KHATWADA 50 |
Page
CS4001NT Programming
END IF
RETURN cardID
END FUNCTION
FUNCTION getCancelCredit()
cardTxt equals to tfCancelCard.getText().trim()
cardID equals to INVALID
IF cardTxt isEmpty()
UPDATE cardid equals to EMPTY
END IF
TRY
cardid equals to Integer.parseInt(cardTxt)
CATCH (Exception f)
IF cardid less than equals to 0
UPDATE cardid equals to INVALID
END IF
RETURN cardid
END FUNCTION
FUNCTION displayCreditCard()
display equals to false
FOR each object stored in Arraylist bankgui
IF that object is instanceof CreditCard THEN
CALL obj.display()
AAYUSH KHATWADA 51 |
Page
CS4001NT Programming
DISPLAY "Details Displayed Done Successfully"
UPDATE display equals to true
ELSE
DISPLAY "Credit not an CreditCard"
RETURN
IF display is Equals to false
DISPLAY "Please add Debit Information First"
RETURN
END IF
END FUNCTION
AAYUSH KHATWADA 52 |
Page
CS4001NT Programming
4 Method Description
A method description is a block of code collection or collection organized together to
carry out a particular operation or action. It is a method for increasing code reusability.
Once a method is created, we utilize it repeatedly. Nobody repeatedly write the same
code again and again. It also allows for simple code modification and readability by
simply adding or removing code blocks. The method is only ever used when we call it
or invoke it.
4.1 Method to add Debit Card
Modifier and types Methods Description
Return type void addDebitCard() addDebitCard is a void return type method
which is used to add details for adding
DebitCard in ArrayList. This method is
called in Add Debit button of DebitCard.
Here in this method we check if text fields
are empty or invalid. If text fields are not
empty and are valid we add the data of text
fields to the ArrayList.
Public access getClientName() getClientName is a method of String return
modifier having type which will return tfClient. The data of
return type String tfClient. JTextField is taken using
getText() method which is further trimmed
using trim() method to exclude empty
space of left and right side of text but it
doesn’t exclude space between two texts.
Public access getBankAccount() getBankAccount is a method of String
modifier having return type which will return tfBankAc. The
return type String data of tfBankAc. JTextField is taken using
getText() method which is further trimmed
AAYUSH KHATWADA 53 |
Page
CS4001NT Programming
using trim() method to exclude empty
space of left and right side of text but it
doesn’t exclude space between two texts.
Public access getIssuerName() getIssuer is a method of String return type
modifier having which will return tfIssuer. The data of
return type String tfIssuer. JTextField is taken using
getText() method which is further trimmed
using trim() method to exclude empty
space of left and right side of text but it
doesn’t exclude space between two texts.
Public access getBalanceAmount() The getBalanceAmount is an integer
modifier having return type method which will return
return type Int amountBank , it takes amount from tfAmt
JTextField and converts it to integer using
parseInt method which is done inside try
and catch to catch any exception, if
bankAmount is not a positive number then
it returns INVALID.
Public access getCardID() The getCardID is an integer return type
modifier having method which will return cardId , it takes
return type Int amount from tfCard JTextField and
converts it to integer using parseInt
method which is done inside try and catch
to catch any exception, if cardId is not a
positive number then it returns INVALID.
Public access getPinNUmber() The getPinNumber is an integer return
modifier having type method which will return PIN Number
return type Int , it takes amount from tfPinNumber
JTextField and converts it to integer using
parseInt method which is done inside try
AAYUSH KHATWADA 54 |
Page
CS4001NT Programming
and catch to catch any exception, if
PinNumber is not a positive number then it
returns INVALID.
Public access sUnique(int card) isUnique is a boolean return type method
modifier having which will return unique. In this method if
Boolean return type the card in bankgui is unique or not. If it is
not unique then a suitable message is
displayed.
Table 1:Method to add Debit Card.
4.2 Method to Withdraw Amount
Modifier and types Methods Description
Return type void withdrawDebit() withdrawDebit is a void return type method
which is used to add details to withdraw
Debit.If the details are not added in
DebitCard then it throws error message.
This method is called in Withdraw Button of
withdrawPanel. Here in this method we
check if text fields are empty or invalid. If
text fields are not empty and are valid card
ID is entered than we create new object to
add the data of text fields to the ArrayList.
Public access getWithdrawDate() getWithdrawDate() is a method of String
modifier having return type which will return
return type String WithdrawBoxYear selected item,
withdrawBoxMonth selected Item and
withdrawBoxDay selected item
Public access getPin() The getPin is an integer return type method
modifier having which will return pinNumber , it takes pin
return type int from tfPin JTextField and converts it to
AAYUSH KHATWADA 55 |
Page
CS4001NT Programming
integer using parseInt method which is
done inside try and catch to catch any
exception, if pinNumber is not a positive
number then it returns INVALID.
Public access getWithdrawAmt() The getWithdrawAmt is an integer return
modifier having type method which will return withdrawAmt,
return type int it takes withdrawAmt from tfwithdrawalAmt
JTextField and converts it to integer using
parseInt method which is done inside try
and catch to catch any exception, if
withdrawAmt is not a positive number then
it returns INVALID.
Public access getWithdrawCardID() The getWithdrawCardID is an integer return
modifier having type method which will return Card , it takes
return type Int cardId from tfCardID JTextField and
converts it to integer using parseInt method
which is done inside try and catch to catch
any exception, if Card is not a positive
number then it returns INVALID.
Public access getCardID() The getCardID is an integer return type
modifier having method which will return cardId , it takes
return type Int cardId from tfCard JTextField and converts
it to integer using parseInt method which is
done inside try and catch to catch any
exception, if cardId is not a positive number
then it returns INVALID.
Table 2: Method to Withdraw Amount.
AAYUSH KHATWADA 56 |
Page
CS4001NT Programming
4.3 Method to Display Debit Card
Modifier and types Methods Description
Public access modifier displayDebitCard() displayDebitCard is a void
with void return type return type method. It
checks the array list first to
see if the object is
instance of DebitCard
then if the object is
instance of DebitCard
then it display a suitable
success message with
values of all textfields and
if not then it displays error
message.
Table 3: Method to Display Debit Card.
4.4 Method to Add CreditCard
Modifier and types Methods Description
Return type void addCreditCard() addCreditCard is a void return type
method which is used to add details to
Card Card.If the details are not added in
CreditCard then it throws error message.
This method is called in Add Credit Button
of creditPanel. Here in this method we
check if text fields are empty or invalid. If
text fields are not empty and invalid than
we add the data of text fields to the
ArrayList.
AAYUSH KHATWADA 57 |
Page
CS4001NT Programming
Public access getExpirationDate() getExpirationDate() is a method of String
modifier having return type which will return
return type String expirationBoxYear selected item,
expirationBoxMonth selected Item and
expirationBoxDay selected item.
Public access getCreClient() getCreClient is a method of String return
modifier having type which will return tfCreClient. The data
return type String of tfCreClient JTextField is taken using
getText() method which is further trimmed
using trim() method to exclude empty
space of left and right side of text but it
doesn’t exclude space between two texts
set to Upper Case.
Public access getCreIssuer() getCreIssuer is a method of String return
modifier having type which will return tfCredIssuer. The
return type String data of tfCredIssuer JTextField is taken
using getText() method which is further
trimmed using trim() method to exclude
empty space of left and right side of text
but it doesn’t exclude space between two
texts and set to Upper Case.
Public access getCreBankAcc() getCreBankAcc is a method of String
modifier having return type which will return
return type Int tfCreBankAcc. The data of tfCreBankAcc
JTextField is taken using getText()
method which is further trimmed using
trim() method to exclude empty space of
left and right side of text but it doesn’t
exclude space between two texts and set
to Upper Case.
AAYUSH KHATWADA 58 |
Page
CS4001NT Programming
Public access getCreCardId() The getCreCardID is an integer return
modifier having type method which will return cardId , it
return type Int takes cardId from tfCreCardId JTextField
and converts it to integer using parseInt
method which is done inside try and catch
to catch any exception, if cardId is Empty
it returns EMPTY.
Public access getInterestRate() The getInterestRate is a double return
modifier having type method which will return interest , it
return type double takes interest rate from tfInterestRate
JTextField and converts it to double using
parseDouble method which is done inside
try and catch to catch any exception, if
interest is Empty it returns EMPTY.
Public access getCvcNum() The getCvcNum is an integer return type
modifier having method which will return cardId , it takes
return type Int cvc number from tfCVC JTextField and
converts it to integer using parseInt
method which is done inside try and catch
to catch any exception, if cvc is Empty it
returns EMPTY.
Public access getCreBalanceAmt() The getCreBalanceAmt is an integer
modifier having return type method which will return Credit
return type Int Balance Amount , it takes credit balance
amount from tfCreBalanceAmt JTextField
and converts it to integer using parseInt
method which is done inside try and catch
to catch any exception, if creBalanceAmt
is Empty it returns EMPTY.
AAYUSH KHATWADA 59 |
Page
CS4001NT Programming
Public access creditIsUnique(int creditIsUnique is a boolean return type
modifier having creCard) method which will return unique. In this
Boolean return type method it checks if the creCard in bankgui
is unique or not. If it is not unique then a
suitable message is displayed.
Table 4:Method to Add Credit Card.
AAYUSH KHATWADA 60 |
Page
CS4001NT Programming
4.5 Method for set Credit Limit
Modifier and types Methods Description
Return type void setCredit() setCredit is a void return type method which is
used to add details to set Credit .If the details
are not added then it throws error message.
This method is called in Set Credit Button of
setCreditLimit. Here in this method we check if
text fields are invalid. If text fields are valid
than we add the data of text fields to the
ArrayList..
Public access getCreLimitCardId() The getCreLimitCardId is an integer return type
modifier having method which will return cardID , it takes cardId
return type Int from tfsetCreditCard JTextField and converts it
to integer using parseInt method which is done
inside try and catch to catch any exception, if
cardID is not a positive number then it returns
INVALID.
Public access getGracePeriod() The getGracePeriod is an integer return type
modifier having method which will return gracePeriod, it takes
return type Int gracePeriod from tfGrace JTextField and
converts it to integer using parseInt method
which is done inside try and catch to catch any
exception, if gracePeriod is not a positive
number then it returns INVALID.
Public access getCreditLimit() The getCreditLimit is an integer return type
modifier having method which will return creditLimit , it takes
return type Int creditLimit from tfCreditLimit JTextField and
converts it to integer using parseInt method
AAYUSH KHATWADA 61 |
Page
CS4001NT Programming
which is done inside try and catch to catch any
exception, if creditLimit is not a positive number
then it returns INVALID.
Table 5: Method for set Credit Limit.
4.6 Method for Cancle Credit Card
Modifier and types Methods Description
Return type void cancelCreditCard() cancelCreditCard is a void return type
method which is used to cancel the
Credit .If the CardId are not added then
it throws error message. This method is
called in Cancel Credit Button of
cancelCreditCard .Here in this method
we check if the cardId match with the
previous card Id or not. If the card Id
match then the credit will be cancelled of
the given card Id.
Public access getCancelCredit() The getCancelCredit is an integer return
modifier having type method which will return cardid , it
return type Int takes cardid from tfCancelCredit
JTextField and converts it to integer
using parseInt method which is done
inside try and catch to catch any
exception, if cardid is not a positive
number then it returns INVALID.
Table 6: Method for Cancle Credit Card.
AAYUSH KHATWADA 62 |
Page
CS4001NT Programming
4.7 Method for Display Credit Card
Modifier and types Methods Description
Public access modifier displayCreditCard() displayCreditCard is a
having return type void void return type method. It
checks the array list first to
see if the object is
instance of CreditCard
then if the object is
instance of DebitCard
then it display a suitable
success message with
values of all textfields and
if not then it displays error
message.
Table 7: Method for Display Credit Card.
AAYUSH KHATWADA 63 |
Page
CS4001NT Programming
5 TESTING
5.1 Test 1
Objective Test that the program can be compiled
and run using command prompt.
Action Open command prompt to compile
and run code:
To compile code:
Type “ javac < name of the java file>
java” to compile the code.
If the compile code execute successfully
To run code:
Type “ java <name of the java file>” to
run code.
Expected Result The program should be compiled and
run successfully using command prompt.
Actual Result Program run successfully using
command prompt.
Conclusion Test successful.
Table 8: Compile and run using command prompt.
AAYUSH KHATWADA 64 |
Page
CS4001NT Programming
Figure 8: Running program using command prompt.
Figure 9: Evidence of Test 1 Successful.
AAYUSH KHATWADA 65 |
Page
CS4001NT Programming
5.2 Test 2
5.2.1 Add DebitCard
Objective To add DebitCard object in arrayList and
show Evidence.
Action Fill all the textFields of DebitPanel with
valid data and click the Add Debit Button.
Expected Result DebitCard Object will be added and
dialog box will be display showing a
message “ Debit Added Successfully”.
Actual Result DebitCard Object added successfully
and dialog box showing a message
“Debit Added Successfully” displayed
successfully.
Conclusion Test Successful with evidence.
Table 9: Test 2 Add DebitCard.
AAYUSH KHATWADA 66 |
Page
CS4001NT Programming
Figure 10: Evidence of Add Debit Successful.
Figure 11: Details after adding Debit Card
AAYUSH KHATWADA 67 |
Page
CS4001NT Programming
5.2.2 ADD CREDIT CARD
Objective To add CreditCard object in ArrayList
and show Evidence.
Action Fill all text fields with proper valid values
and click the Add Credit Button.
Expected Result CreditCard Object will be added and
dialog box will be display showing a
message “ Credit Added Successfully for
Mr/Mrs (client name) THANK YOU”.
Actual Result CreditCard Object added successfully
and dialog box showing a message “
Credit Added Successfully for Mr/Mrs
(client name) THANK YOU” displayed
successfully.
Conclusion Test successful with evidence.
Table 10: Testing of Add Credit Card.
AAYUSH KHATWADA 68 |
Page
CS4001NT Programming
Figure 12: Credit Card
Fi added successfully.
AAYUSH KHATWADA 69 |
Page
CS4001NT Programming
5.2.3 Withdraw amount from Debit Card
Objective To withdraw amount from DebiitCard
and show Evidence.
Action Fill all text fields with proper valid values
and click the Withdraw Button.
Expected Result Amount will be withdrawn from
DebitCard and dialog box will be display
showing a message “Please see the
terminal for the message.
THANK YOU”.
Actual Result Amount withdrawn successfully from
DebitCard and dialog showing a
message “Please see the terminal for the
message. THANK YOU” displayed
successfully.
Conclusion Test successful with evidence.
Table 11: Testing of Withdraw amount from Debit Card
AAYUSH KHATWADA 70 |
Page
CS4001NT Programming
Figure 14 : Money withdrawn successfully.
Figure 13: Details after money withdrawn.
AAYUSH KHATWADA 71 |
Page
CS4001NT Programming
5.2.4 Set the Credit Limit
Objective To set the credit Limit from CreditCard
and show Evidence.
Action Fill all text fields with proper valid values
and click the Set Credit Button.
Expected Result Credit will be set from CreditCard and
dialog box will be display showing a
message “Credit Limit set successfully
for card Id (card Id) , Please see the
terminal for the message.
THANK YOU”.
Actual Result Credit will be set successfully from
CreditCard and dialog box showing a
message “Credit Limit set successfully
for card Id (card Id) , Please see the
terminal for the message.
THANK YOU” displayed successfully.
Conclusion Test successful with evidence.
Table 12: Testing of Set Credit Limit.
AAYUSH KHATWADA 72 |
Page
CS4001NT Programming
Figure 15: Credit Card added successfully.
Figure 16: Details of Credit Card after
credit limit set.
AAYUSH KHATWADA 73 |
Page
CS4001NT Programming
5.2.5 Cancel the Credit Card
Objective To cancle the CreditCard from
CreditCard and show Evidence.
Action Fill all text fields with proper valid values
and click the Cancle Credit Button.
Expected Result Credit will be cancelled from CreditCard
and dialog box will be display showing a
message “Credit Limit set successfully
for card Id (card Id) , Please see the
terminal for the message.
THANK YOU”.
Actual Result Credit will be set successfully from
CreditCard and dialog box showing a
message “Credit Limit set successfully
for card Id (card Id) , Please see the
terminal for the message.
THANK YOU” displayed successfully.
Conclusion Test successful with evidence.
Table 13: Testing of Cancel Credit Card
AAYUSH KHATWADA 74 |
Page
CS4001NT Programming
Figure 17: Credit Card cancelled successfully.
AAYUSH KHATWADA 75 |
Page
CS4001NT Programming
5.3 Testing 3
5.3.1 Debit Unique card Id
Objective To check whether the Debit Card card id
Is unique or not and show Evidence.
Action Enter the same card id twice and click
add debit button.
Expected Result Error would be occurred and dialog box
with error message will be displayed
showing that “ Card id must be unique”.
Actual Result Error occurred and dialog box with error
message displayed successfully.
showing that “ Card id must be unique”
Conclusion Card id unique test successful.
Table 14: Debit card unique test.
AAYUSH KHATWADA 76 |
Page
CS4001NT Programming
Figure 18: Debit card id must be unique(error).
AAYUSH KHATWADA 77 |
Page
CS4001NT Programming
5.3.2 Withdraw card id mismatch
Objective To check whether the withdraw panel
card id match with debit card id or not
show evidence.
Action Enter different card id in withdraw panel
and click withdraw button.
Expected Result Error would be occurred and dialog box
with error message will be displayed
showing that “ Incorrect card id”
Actual Result Error occurred and dialog box with error
message displayed successfully.
showing that “ Incorrect card id”.
Conclusion Withdraw Card id mismatch test
successful.
Table 15: Withdraw card id not matched.
AAYUSH KHATWADA 78 |
Page
CS4001NT Programming
Figure 19: Withdraw card id does not match
AAYUSH KHATWADA 79 |
Page
CS4001NT Programming
5.3.3 Debit invalid card id
Objective To check whether the debit card id takes
negative integer or not show evidence.
Action Enter negative value in card id and click
add debit button.
Expected Result Error would be occurred and dialog box
with error message will be displayed
showing that “Please enter valid card id”.
Actual Result Error occurred and dialog box with error
message displayed successfully.
showing that “Please enter valid card id”.
Conclusion Test successful Debit card text field
doesnot take negative value.
Table 16: Debit Card id Invalid.
AAYUSH KHATWADA 80 |
Page
CS4001NT Programming
Figure 20: Debit Card Negative integer error.(Invalid)
AAYUSH KHATWADA 81 |
Page
CS4001NT Programming
5.3.4 Credit Unique Card ID
Objective To check whether the Credit Card card id
is unique or not and show Evidence.
Action Enter the same card id twice and click
add credit button.
Expected Result Error would be occurred and dialog box
with error message will be displayed
showing that “ Card id must be unique”.
Actual Result Error occurred and dialog box with error
message displayed successfully.
showing that “ Card id must be unique”
Conclusion Credit Card Card id unique test
successful.
Table 17 : Credit card id unique test.
AAYUSH KHATWADA 82 |
Page
CS4001NT Programming
Figure 21: Credit Card id unique( error).
AAYUSH KHATWADA 83 |
Page
CS4001NT Programming
5.3.5 Set Credit Limit Card ID mismatch
Objective To check whether the set credit panel
card id match with credit card id or not
show evidence.
Action Enter different card id in set credit panel
and click set credit button.
Expected Result Error would be occurred and dialog box
with error message will be displayed
showing that “ Incorrect card id”
Actual Result Error occurred and dialog box with error
message displayed successfully.
showing that “ Incorrect card id”.
Conclusion Set Credit Card id mismatch test
successful.
Table 18: Set credit limit card id test.
Figure 22: Set Credit Card Id doesnot matched.( Error)
AAYUSH KHATWADA 84 |
Page
CS4001NT Programming
5.3.6 Cancel credit card id mismatch
Objective To check whether the cancel credit card
id match with credit card id or not show
evidence.
Action Enter different card id in cancel credit
and click cancle credit button.
Expected Result Error would be occurred and dialog box
with error message will be displayed
showing that “ Card id Does not exist”
Actual Result Error occurred and dialog box with error
message displayed successfully.
showing that “Card id Does not exist”.
Conclusion Cancel Credit Card id mismatch test
successful.
Table 19: Cancel credit card id test.
Figure 23: Cancel credit card id not matched. (Error)
AAYUSH KHATWADA 85 |
Page
CS4001NT Programming
5.3.7 Credit card id invalid
Objective To check whether the credit card id takes
negative integer or not show evidence.
Action Enter negative value in card id and click
add credit button.
Expected Result Error would be occurred and dialog box
with error message will be displayed
showing that “Please enter positive
number in card id”.
Actual Result Error occurred and dialog box with error
message displayed successfully.
showing that “Please enter positive
number in card id”.
Conclusion Test successful Credit card text field
doesnot take negative value.
Table 20: Credit card id negative test.
Figure 24: Credit Card Id negative integer. (Invalid)
AAYUSH KHATWADA 86 |
Page
CS4001NT Programming
6 Error Detection and Correction
Errors are the mistakes that could occur during coding or programming. They occur
during programming due to some factors like carelessness.
There are three types of errors that may occur during programming:
6.1 Syntax Error
Syntax errors in programming are the incorrect labels, spelling and punctuation
issues and other mistakes in the source code. When compiler finds something
wrong with our program it throws a syntax error.
Some of the syntax errors that appeared in my code are shown in beneath
figure:
• Error Detection
Figure 25: Syntax error detection.
In line 37, the error is detected which shows ; expected which means semicolon
is missing in frame().
AAYUSH KHATWADA 87 |
Page
CS4001NT Programming
• Error Correction
Figure 26: Syntax error correction.
In line 37, the error is solved by inserting semicolon in the frame().
6.2 Symmetric Error
A symmetric error occurs when a program, which is syntactically good , but has
a bug that is only found during program execution. When a runtime error occurs
java program the compiler pinpoints the lines of code that are at fault. It can be
used to identity the root cause behind the error.
• Error Detection
Figure 27 : Symmetric error detection.
AAYUSH KHATWADA 88 |
Page
CS4001NT Programming
Figure 28 : Exception of symmetric error.
Figure 29 : Symmetric error location in program.
From the above images it show that I have entered card id in string “ffff” but
in code my card id string is updated using Integer parseInt which only takes
integer values from the user. Due to this exception has been found.
AAYUSH KHATWADA 89 |
Page
CS4001NT Programming
• Error Correction
Figure 30: Symmetric error correction in program.
Figure 31 : Symmetric error correction.
AAYUSH KHATWADA 90 |
Page
CS4001NT Programming
Figure 32 : Exception solved(not found) symmetric
The above symmetric error is solved by using try catch method for debit card id.
After using try catch method program is running successfully but as the above image
error dialog box occurred because I inserted dialog box if invalid data is entered in
card id.
6.3 Logical Error
Logical errors are the type of errors that occurs in result. Logical errors are not
detected during compile process. Even if the program is compiled without
syntax errors there is possibility of getting logical error. If we compile a program
and got results that shouldn’t be there then there is a possibility that we had got
a logical error in that program.
AAYUSH KHATWADA 91 |
Page
CS4001NT Programming
Here in my program there is a logical error that gives unexpected output.
Figure 33 : Debit Card logical error .
From the image above it shows that I have entered Client Name as “Aayush”
and Issuer Bank as “IIC BANK” but when I display the details the name of bank
is appeared in Client Name and name of client in Issuer Bank.
AAYUSH KHATWADA 92 |
Page
CS4001NT Programming
Figure 34 : Details after debit card added.
This error is occurred because in getter method of clientName I have returned the
value of textField of issuerBank and in getter method issuerBank I have returned the
value of textField of clientName. To fix this error getter methods should be written in
their specific places.
• Error Detection
Figure 35: Error detection of logical error.
AAYUSH KHATWADA 93 |
Page
CS4001NT Programming
• Error Correction
Figure 36 : Logical Error correction
AAYUSH KHATWADA 94 |
Page
CS4001NT Programming
7 Conclusion
The entire thing has a period. I started this assignment, and now I have reached to the
ending and I would like to end this work with this conclusion. Java is an object-oriented
programming language. It is general-purpose programming language that was
primarily created to let developed java programs to run without recompilation on any
platforms that support java.
First and foremost, I would like thank my module tutor Mr.Jeewan Dhamala for
assigning us this work, which allowed us to conduct our own research and finish my
report. I am also very grateful to my seniors my classmates and the Online websites
which help in this work. This coursework assisted in learning more about how Java
framework GUI and ActionListener functions as well as how it has influenced the real
world and how java has impact in this rapid growing technology of this world.
Understanding java queries has been greatly aided by the syntax and coding in
general. Any task is never easy in beginning but once we do, it begins and continue
in its flow, and for the first time, I continue working on and practicing it. After much
effort, all of the given coursework task were eventually finished on time and I am very
happy to get it done by time.
This project of GUI programming was given to us in order to develop our knowledge
on coding and constructing GUI programs. Programs are the collection of information
that tells the computer what to do and how to do. The way of writing or interpreting a
program is known as programming. The way of programming is determined by
algorithm which consists of flowchart or pseudocode. Here in this project at first, I have
created a class diagram to show relationship between different classes. The class
diagram is a type of UML diagram that is used to describe a static diagram by mapping
the structure of a system using classes, properties, relations, and actions amongst the
various components. GUI is a best concept that I have learned till this day. GUI helps
in communication between user and computer.
Finally, I completed the given assignment after many research and my dedication
towards this coursework. I gained a lot of knowledge about coding , programming java
GUI how it works in real world and how it is impacting our life as well. This course
AAYUSH KHATWADA 95 |
Page
CS4001NT Programming
also help to enhance my coding skills and polish it. My understanding of inheritance,
SWINGS, AWT in java has greatly expanded as a result of this assignment, and now
I have a solid knowledge of documentation’s, method descriptions, pseudocode and
class diagrams, frames and GUI.
8 References
bhagiradhrayini25, 2021. Introduction to Microsoft Word. [Online]
Available at: https://www.geeksforgeeks.org/introduction-to-microsoft-word/
[Accessed 06 05 2023].
BlueJ, 2023. About BlueJ. [Online]
Available at: https://www.bluej.org/about.html
[Accessed 29 04 2023].
EDUCBA, 2023. Draw.io Alternatives. [Online]
Available at: https://www.educba.com/draw-io-alternatives/
[Accessed 06 05 2023].
goelshubhangi3118, 2023. Introduction to Java. [Online]
Available at: https://www.geeksforgeeks.org/introduction-to-java/
[Accessed 26 04 2023].
javaTPoint, 2023. UML Class Diagram. [Online]
Available at: https://www.javatpoint.com/uml-class-diagram
[Accessed 29 04 2023].
Levy, S., 2023. graphical user interface. [Online]
Available at: https://www.britannica.com/technology/graphical-user-interface
[Accessed 26 04 2023].
Nanyang Technological University, 2021. Java Programming Tutorial Programming
Graphical user Interface(GUI). [Online]
Available at: https://www3.ntu.edu.sg/home/ehchua/programming/java/j4a_gui.html
[Accessed 26 04 2023].
AAYUSH KHATWADA 96 |
Page
CS4001NT Programming
Pedamkar, P., 2023. What is Visual Studio Code?. [Online]
Available at: https://www.educba.com/what-is-visual-studio-code/
[Accessed 06 05 2023].
AAYUSH KHATWADA 97 |
Page
CS4001NT Programming
AAYUSH KHATWADA 98 |
Page
CS4001NT Programming
AAYUSH KHATWADA 99 |
Page
CS4001NT Programming
AAYUSH KHATWADA 100 |
Page
CS4001NT Programming
AAYUSH KHATWADA 101 |
Page
CS4001NT Programming
9 APPENDIX
package course_work;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.event.ActionListener;
import java.util.ArrayList;
public class BankGUI{
private static final int INVALID = -1;
private static final int EMPTY = -1;
private JFrame f,debitF,creditF;
private JMenuBar menu;
private JMenu m1,m2;
private JMenuItem item1, item2,item3;
private JPanel mainPanel, debitPanel,
creditPanel,withdrawPanel,setCreditPanel,cancelCreditPanel;
private JLabel bankGui, debitCard, creditCard, debitTitle,creditTitle, card, client,
bank ,account, amount, pin ,withdrawalAmount, withdrawDate, cvc, creditLimit,
interestRate, grace,expirationDate;
private JTextField tfCard ,tfCardID, tfClient, tfIssuer, tfBankAc,
tfAmt,tfPinNumber,tfPin, tfWithdrawalAmt, tfCVC, tfCreditLimit, tfInterestRate,
tfGrace,tfCreCardId,tfCreClient,tfCreBankAcc,tfCredIssuer,tfCreBalanceAmt,tfsetCre
ditCard,tfCancelCard;
AAYUSH KHATWADA 102 |
Page
CS4001NT Programming
private JComboBox<String> withdrawalBoxYear,withdrawalBoxMonth,
withdrawalBoxDay, expirationBoxYear,expirationBoxMonth,expirationBoxDay;
private JButton addDebit , addCredit, withdraw, setCredit, cancelCreditBtn,
display, clear,back,clearCredit,backCredit;
private ArrayList <BankCard> bankgui = new ArrayList<>();
public BankGUI()
frame();
menu();
mainPanel();
debitPanel();
withdrawPanel();
creditPanel();
setCreditPanel();
cancelCreditPanel();
//Method for frame
public void frame()
AAYUSH KHATWADA 103 |
Page
CS4001NT Programming
f = new JFrame("BankGUI");
f.setSize(550,500);
f.setLayout(null);
f.getContentPane().setBackground(Color.white);
f.setLocationRelativeTo(null);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setResizable(false);
//Method for menu
public void menu()
menu = new JMenuBar();
f.setJMenuBar(menu);
m1 = new JMenu("File");
menu.add(m1);
item1 = new JMenuItem("Exit");
item1.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E,
ActionEvent.CTRL_MASK));
item1.addActionListener(new ActionListener() {
AAYUSH KHATWADA 104 |
Page
CS4001NT Programming
public void actionPerformed(ActionEvent a){
System.exit(0);
});
m1.add(item1);
m2 = new JMenu("About");
menu.add(m2);
item2 = new JMenuItem("Version");
item2.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V,ActionEvent.CTRL_
MASK));//shortcut key for item 1
item2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent v){
JOptionPane.showMessageDialog(f,"Version Second Semester \n \t
BankGUI","Version",(1));
});
m2.add(item2);
AAYUSH KHATWADA 105 |
Page
CS4001NT Programming
item3 = new JMenuItem("Developer");
item3.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D,ActionEvent.CTRL_
MASK));//shortcut key for showing developer dialog
item3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent d){
JOptionPane.showMessageDialog(f,"Developer Name \n \t Aayush
Khatiwada","Developer",JOptionPane.INFORMATION_MESSAGE);
});
m2.add(item3);
//menu.setVisible(true);
//Method for MainPanel of the frame
public void mainPanel()
mainPanel = new JPanel();
mainPanel.setBounds(0, 0,700, 700);
mainPanel.setLayout(null);
AAYUSH KHATWADA 106 |
Page
CS4001NT Programming
mainPanel.setBackground(Color.white);
bankGui = new JLabel("BANK GUI");
bankGui.setFont(new Font("Avallon",Font.PLAIN,40));
bankGui.setBounds(170, 20, 200, 80);
mainPanel.add(bankGui);
debitCard = new JLabel("Click here to enter DebitCard");
debitCard.setFont(new Font("Arial",Font.PLAIN,20));
debitCard.setBounds(30, 150, 300, 30);
mainPanel.add(debitCard);
creditCard = new JLabel("Click here to enter CreditCard");
creditCard.setFont(new Font("Arial",Font.PLAIN,20));
creditCard.setBounds(30, 250, 300, 30);
mainPanel.add(creditCard);
JButton addDebitBtn = new JButton("Add Debit");
addDebitBtn.setBounds(380,150,140,40);
AAYUSH KHATWADA 107 |
Page
CS4001NT Programming
addDebitBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent a){
f.setVisible(false);
debitF.setVisible(true);
debitPanel.setVisible(true);
});
mainPanel.add(addDebitBtn);
JButton addCreditBtn = new JButton("Add Credit");
addCreditBtn.setBounds(380,250,140,40);
addCreditBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent a){
f.setVisible(false);
//debitF.setVisible(false);
creditF.setVisible(true);
creditPanel.setVisible(true);
});
mainPanel.add(addCreditBtn);
AAYUSH KHATWADA 108 |
Page
CS4001NT Programming
JButton exitButton = new JButton("Exit");
exitButton.setBounds(200, 350, 100, 30);
exitButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent a){
System.exit(0);
});
mainPanel.add(exitButton);
f.add(mainPanel);
//Method for debitPanel of the frame
public void debitPanel()
debitF = new JFrame("Debit Card");
debitF.setSize(800,700);
debitF.getContentPane().setBackground(Color.DARK_GRAY);
debitF.setLayout(null);
debitF.setLocationRelativeTo(null);
debitF.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
debitF.setResizable(false);
AAYUSH KHATWADA 109 |
Page
CS4001NT Programming
debitPanel = new JPanel();
debitPanel.setBounds(45,50,700,300);
debitPanel.setLayout(null);
debitPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtched
Border(),"Debit Card"));
debitPanel.setBackground(Color.gray);
debitF.add(debitPanel);
//Initalizing JLables inside DebitPanel
client = new JLabel("Client Name =");//JLabel of Client
client.setBounds(20, 40, 80, 30);
debitPanel.add(client);
account = new JLabel("Bank Account =");// Jlable of Bank
account.setBounds(20, 80, 100, 30);
debitPanel.add(account);
card = new JLabel("Card ID = ");//Jlabel of Card ID
card.setBounds(20, 120, 90, 30);
debitPanel.add(card);
bank = new JLabel("Issuer Bank =");//Jlabel
AAYUSH KHATWADA 110 |
Page
CS4001NT Programming
bank.setBounds(20, 160, 90, 30);
debitPanel.add(bank);
amount = new JLabel("Balance Amount =");//jlabel
amount.setBounds(20, 200, 120, 30);
debitPanel.add(amount);
pin = new JLabel("PIN Number =");//jlabel
pin.setBounds(20, 240, 90, 30);
debitPanel.add(pin);
//Initalizing JTextFields of all jLables inside debitPanel
tfClient = new JTextField();
tfClient.setBounds(120, 35, 200, 30);
debitPanel.add(tfClient);
tfBankAc = new JTextField();
tfBankAc.setBounds(120, 80, 200, 30);
debitPanel.add(tfBankAc);
tfCard = new JTextField();
tfCard.setBounds(120, 120, 200, 30);
debitPanel.add(tfCard);
AAYUSH KHATWADA 111 |
Page
CS4001NT Programming
tfIssuer = new JTextField();
tfIssuer.setBounds(120, 160, 200, 30);
debitPanel.add(tfIssuer);
tfAmt = new JTextField();
tfAmt.setBounds(120, 200, 200, 30);
debitPanel.add(tfAmt);
tfPinNumber = new JTextField();
tfPinNumber.setBounds(120, 240, 200, 30);
debitPanel.add(tfPinNumber);
back = new JButton("Back");
back.setBounds(40, 600, 100, 30);
back.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent a){
debitF.setVisible(false);
// debitPanel.setVisible(false);
f.setVisible(true);
});
AAYUSH KHATWADA 112 |
Page
CS4001NT Programming
debitF.add(back);
clear = new JButton("Clear");
clear.setBounds(580, 250, 100, 30);
clear.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent a){
clearDebit();
});
debitPanel.add(clear);
display = new JButton("Display");
display.setBounds(680,600,100,30);
display.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent d){
displayDebitCard();
});
debitF.add(display);
AAYUSH KHATWADA 113 |
Page
CS4001NT Programming
addDebit = new JButton("Add Debit");
addDebit.setBounds(400, 130, 150, 50);
addDebit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent a){
addDebitCard();
withdrawPanel.setVisible(true);
});
debitPanel.add(addDebit);
//Creating a label for DebitPanel Title
debitTitle = new JLabel("Debit Card");
debitTitle.setFont(new Font("Avallon", Font.BOLD, 40));
debitTitle.setBounds(300,05,250,40);
debitTitle.setForeground(Color.WHITE);
debitF.add(debitTitle);
f.setVisible(true);
AAYUSH KHATWADA 114 |
Page
CS4001NT Programming
//creating a method for withdraw panel inside debitFrame
public void withdrawPanel()
withdrawPanel = new JPanel();
withdrawPanel.setLayout(null);
withdrawPanel.setBackground(Color.gray);
withdrawPanel.setBounds(45, 360, 700, 230);
withdrawPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtc
hedBorder(),"Withdraw Amount"));
withdrawPanel.setVisible(true);
debitF.add(withdrawPanel);
withdrawalAmount = new JLabel("Withdrawal Amount = ");
withdrawalAmount.setBounds(30, 20, 150, 30);
withdrawPanel.add(withdrawalAmount);
withdrawDate = new JLabel("Date of Withdraw =");
withdrawDate.setBounds(30, 70, 120, 30);
withdrawPanel.add(withdrawDate);
pin = new JLabel("PIN Number =");
AAYUSH KHATWADA 115 |
Page
CS4001NT Programming
pin.setBounds(30, 130, 120, 30);
withdrawPanel.add(pin);
card = new JLabel("Card ID =");
card.setBounds(30,180,120,30);
withdrawPanel.add(card);
tfCardID = new JTextField();
tfCardID.setBounds(180,180,200,30);
withdrawPanel.add(tfCardID);
tfWithdrawalAmt = new JTextField();
tfWithdrawalAmt.setBounds(180, 20, 200, 30);
withdrawPanel.add(tfWithdrawalAmt);
tfPin = new JTextField();
tfPin.setBounds(180, 130, 200, 30);
withdrawPanel.add(tfPin);
AAYUSH KHATWADA 116 |
Page
CS4001NT Programming
withdraw = new JButton("Withdraw");
withdraw.setBounds(480, 70, 170, 30);
withdraw.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent a){
withdrawDebit();
});
withdrawPanel.add(withdraw);
String Year[] = new String[25];
Year[0] = "Year";
int y = 2000;
for (int i = 1; i<=24; i++){
Year[i] = String.valueOf(y);
y++;
String Month[] = { "Month", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",
"Sep", "Oct", "Nov",
"Dec" };
String Day[] = new String[32];
AAYUSH KHATWADA 117 |
Page
CS4001NT Programming
Day[0] = "Day";
int D = 1;
for (int i = 1; i < 32; i++) {
Day[i] = String.valueOf(D);
D++;
withdrawalBoxYear = new JComboBox<String>(Year);
withdrawalBoxMonth = new JComboBox<String>(Month);
withdrawalBoxDay = new JComboBox<String>(Day);
withdrawalBoxYear.setBounds(180, 70, 70, 30);
withdrawalBoxYear.setVisible(true);
withdrawPanel.add(withdrawalBoxYear);
withdrawalBoxMonth.setBounds(250, 70, 70, 30);
withdrawalBoxMonth.setVisible(true);
withdrawPanel.add(withdrawalBoxMonth);
withdrawalBoxDay.setBounds(320, 70, 50, 30);
withdrawalBoxDay.setVisible(true);
withdrawPanel.add(withdrawalBoxDay);
AAYUSH KHATWADA 118 |
Page
CS4001NT Programming
//clear button for DebitCard
clear = new JButton("Clear");
clear.setBounds(580, 190, 100, 30);
clear.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent a){
clearWithdraw();
});
withdrawPanel.add(clear);
mainPanel.setVisible(true);
withdrawPanel.setVisible(false);
//Method To clear the debitPanel panel text Fields
public void clearDebit()
tfClient.setText("");
tfIssuer.setText("");
AAYUSH KHATWADA 119 |
Page
CS4001NT Programming
tfCard .setText("");
tfBankAc.setText("");
tfPinNumber.setText("");
tfAmt.setText("");
//Method To clear the withdrawPanel text Fields
public void clearWithdraw(){
tfWithdrawalAmt.setText("");
tfPin.setText("");
tfCardID.setText("");
withdrawalBoxYear.setSelectedIndex(0);
withdrawalBoxMonth.setSelectedIndex(0);
withdrawalBoxDay.setSelectedIndex(0);
// Method for credit pannel
public void creditPanel()
creditF = new JFrame("Credit Card");
creditF.setSize(800,700);
creditF.setLayout(null);
AAYUSH KHATWADA 120 |
Page
CS4001NT Programming
creditF.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
creditF.setResizable(false);
creditF.getContentPane().setBackground(Color.DARK_GRAY);
creditF.setLocationRelativeTo(null);
creditPanel = new JPanel();
creditPanel.setLayout(null);
creditPanel.setBounds(45,50,700,300);
creditPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtche
dBorder(),"Credit Card"));
creditPanel.setBackground(Color.gray);
creditF.add(creditPanel);
//Initalizing JLables inside CreditPanel
client = new JLabel("Client Name =");//JLabel of Client
client.setBounds(20, 40, 80, 30);
creditPanel.add(client);
account = new JLabel("Bank Account =");// Jlable of Bank
account.setBounds(20, 80, 100, 30);
creditPanel.add(account);
AAYUSH KHATWADA 121 |
Page
CS4001NT Programming
card = new JLabel("Card ID = ");//Jlabel of Card ID
card.setBounds(20, 120, 90, 30);
creditPanel.add(card);
bank = new JLabel("Issuer Bank =");//Jlabel
bank.setBounds(20, 160, 90, 30);
creditPanel.add(bank);
amount = new JLabel("Balance Amount =");//jlabel
amount.setBounds(20, 200, 120, 30);
creditPanel.add(amount);
cvc = new JLabel("CVC Number:");
cvc.setBounds(400, 70, 80, 30);
creditPanel.add(cvc);
interestRate = new JLabel("Interest Rate:");
interestRate.setBounds(400, 120, 80, 30);
creditPanel.add(interestRate);
expirationDate = new JLabel("Expiration Date:");
expirationDate.setBounds(400, 170, 100, 30);
creditPanel.add(expirationDate);
AAYUSH KHATWADA 122 |
Page
CS4001NT Programming
String Year[] = new String[25];
Year[0] = "Year";
int y = 2000;
for (int i = 1; i<=24; i++){
Year[i] = String.valueOf(y);
y++;
String Month[] = { "Month", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",
"Sep", "Oct", "Nov",
"Dec" };
String Day[] = new String[32];
Day[0] = "Day";
int D = 1;
for (int i = 1; i < 32; i++) {
Day[i] = String.valueOf(D);
D++;
expirationBoxYear = new JComboBox<String>(Year);
AAYUSH KHATWADA 123 |
Page
CS4001NT Programming
expirationBoxMonth = new JComboBox<String>(Month);
expirationBoxDay = new JComboBox<String>(Day);
expirationBoxYear.setBounds(500, 170, 70, 30);
expirationBoxYear.setVisible(true);
creditPanel.add(expirationBoxYear);
expirationBoxMonth.setBounds(570, 170, 70, 30);
expirationBoxMonth.setVisible(true);
creditPanel.add(expirationBoxMonth);
expirationBoxDay.setBounds(640, 170, 50, 30);
expirationBoxDay.setVisible(true);
creditPanel.add(expirationBoxDay);
//Initalizing JTextFields of all jLables inside creditPanel
tfCreClient = new JTextField();
tfCreClient.setBounds(120, 35, 200, 30);
creditPanel.add(tfCreClient);
tfCreBankAcc = new JTextField();
tfCreBankAcc.setBounds(120, 80, 200, 30);
creditPanel.add(tfCreBankAcc);
AAYUSH KHATWADA 124 |
Page
CS4001NT Programming
tfCreCardId = new JTextField();
tfCreCardId.setBounds(120, 120, 200, 30);
creditPanel.add(tfCreCardId);
tfCredIssuer = new JTextField();
tfCredIssuer.setBounds(120, 160, 200, 30);
creditPanel.add(tfCredIssuer);
tfCreBalanceAmt = new JTextField();
tfCreBalanceAmt.setBounds(120, 200, 200, 30);
creditPanel.add(tfCreBalanceAmt);
tfCVC = new JTextField();
tfCVC.setBounds(480, 70, 200, 30);
creditPanel.add(tfCVC);
tfInterestRate = new JTextField();
tfInterestRate.setBounds(480, 120, 200, 30);
creditPanel.add(tfInterestRate);
//Adding back button and registering action listner in Back Button
backCredit = new JButton("Back");
AAYUSH KHATWADA 125 |
Page
CS4001NT Programming
backCredit.setBounds(60, 600, 100, 30);
backCredit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent a){
creditF.setVisible(false);
f.setVisible(true);
});
creditF.add(backCredit);
//Adding clear button registering action listner in clear Button
clearCredit = new JButton("Clear");
clearCredit.setBounds(160, 250, 100, 30);
clearCredit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent a){
clearCre();
});
creditPanel.add(clearCredit);
//Adding back button and registering action listner in Back Button
display = new JButton("Display");
display.setBounds(650,600,100,30);
AAYUSH KHATWADA 126 |
Page
CS4001NT Programming
display.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent d){
displayCreditCard();
});
creditF.add(display);
//Adding addCredit Button and Registering action Listner in that button
addCredit = new JButton("Add credit");
addCredit.setBounds(350, 250, 120, 30);
addCredit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent a){
addCreditCard();
});
creditPanel.add(addCredit);
//Title of Credit Frame
creditTitle = new JLabel();
creditTitle.setText("Credit Card");
creditTitle.setFont(new Font("Avallon", Font.BOLD, 40));
AAYUSH KHATWADA 127 |
Page
CS4001NT Programming
creditTitle.setForeground(Color.WHITE);
creditTitle.setBounds(300,05,250,40);
creditF.add(creditTitle);
// setCreditPanel();
//Method for setcreditPanel to set the creditLimit
public void setCreditPanel()
setCreditPanel = new JPanel();
setCreditPanel.setBounds(50, 380, 370, 200);
setCreditPanel.setLayout(null);
setCreditPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtc
hedBorder(),"Set Credit Amount"));
setCreditPanel.setBackground(Color.gray);
setCreditPanel.setVisible(true);
creditF.add(setCreditPanel);
//Creating and adding JLables for setCreditPanel
card = new JLabel("Card Id: ");
card.setBounds(30, 110, 150, 30);
AAYUSH KHATWADA 128 |
Page
CS4001NT Programming
setCreditPanel.add(card);
creditLimit = new JLabel("Credit Limit:");
creditLimit.setBounds(30, 20, 150, 30);
setCreditPanel.add(creditLimit);
grace = new JLabel("Grace Period:");
grace.setBounds(30, 70, 100, 30);
setCreditPanel.add(grace);
//Adding JTextFields for setCreditPanel
tfsetCreditCard = new JTextField();
tfsetCreditCard.setBounds(130, 110, 200, 30);
setCreditPanel.add(tfsetCreditCard);
tfGrace = new JTextField();
tfGrace.setBounds(130, 70, 200, 30);
setCreditPanel.add(tfGrace);
tfCreditLimit = new JTextField();
tfCreditLimit.setBounds(130, 20, 200, 30);
setCreditPanel.add(tfCreditLimit);
AAYUSH KHATWADA 129 |
Page
CS4001NT Programming
//Adding setCredit button and registering action listner in it
setCredit = new JButton("Set Credit");
setCredit.setBounds(150, 160, 180, 30);
setCredit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent a){
setCredit();
});
setCreditPanel.add(setCredit);
//Method for cancel Credit
public void cancelCreditPanel(){
cancelCreditPanel = new JPanel();
cancelCreditPanel.setBounds(440, 380, 300, 200);
cancelCreditPanel.setLayout(null);
cancelCreditPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.creat
eEtchedBorder(),"Cancle Credit Amount"));
cancelCreditPanel.setBackground(Color.gray);
cancelCreditPanel.setVisible(true);
creditF.add(cancelCreditPanel);
//Adding JLables for cancelCreditPanel
AAYUSH KHATWADA 130 |
Page
CS4001NT Programming
card = new JLabel(" Card ID:");
card.setBounds(20,60,100,20);
cancelCreditPanel.add(card);
//JTextFields for cancelCreditPanel
tfCancelCard = new JTextField();
tfCancelCard.setBounds(80,60,200,30);
cancelCreditPanel.add(tfCancelCard);
cancelCreditBtn = new JButton("Cancle Credit");
cancelCreditBtn.setBounds(100, 150, 120, 30);
cancelCreditPanel.add(cancelCreditBtn);
cancelCreditBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e){
cancelCreditCard();
});
cancelCreditPanel.add(cancelCreditBtn);
//Method for Clearing CreditCard TextFields
AAYUSH KHATWADA 131 |
Page
CS4001NT Programming
public void clearCre(){
tfCreClient.setText("");
tfCreBankAcc.setText("");
tfCreBalanceAmt.setText("");
tfCreCardId.setText("");
tfCredIssuer.setText("");
tfGrace.setText("");
tfCVC.setText("");
tfInterestRate.setText("");
tfGrace.setText("");
tfCreditLimit.setText("");
tfsetCreditCard.setText(" ");
expirationBoxYear.setSelectedIndex(0);
expirationBoxMonth.setSelectedIndex(0);
expirationBoxDay.setSelectedIndex(0);
//Methhod to Add DebitCard
public void addDebitCard(){
String client = getClientName();
AAYUSH KHATWADA 132 |
Page
CS4001NT Programming
String bank= getIssuerName();
String account= getBankAccount();
//Checking whether the textfields are empty or not
if(client.equals("") || bank.isEmpty() || account.isEmpty()){
JOptionPane.showMessageDialog(f,"Please fill the form","Error!!",2);
return;
int amount = getBalanceAmount();
int pin = getPinNUmber();
int card = getCardID();
//Checking if integers are less than 0 or not
if (amount<=0){
amount=INVALID;
if(pin<=0){
pin=INVALID;
if(card<=0){
card=INVALID;
AAYUSH KHATWADA 133 |
Page
CS4001NT Programming
//Checking if data are invalid and displaying suitable message if they are invalid
if (amount==INVALID){
JOptionPane.showMessageDialog(f, "Please enter appropriate Balance
Amount","Error",
JOptionPane.ERROR_MESSAGE);
return;
if (pin==INVALID){
JOptionPane.showMessageDialog(f, "Please enter valid Pin Number","Error",
JOptionPane.ERROR_MESSAGE);
return;
if (card==INVALID){
JOptionPane.showMessageDialog(f, "Please enter valid card Id","Error",
JOptionPane.ERROR_MESSAGE);
return;
//Checking if data are unique and invalid or not
if(amount==INVALID&&pin==INVALID&&card==INVALID){
JOptionPane.showMessageDialog(f,"invalid balanceamount, pin number or
card id","Error!!",2);
AAYUSH KHATWADA 134 |
Page
CS4001NT Programming
return;
if(isUnique(card)){
bankgui.add(new DebitCard(amount,card,account,bank,client,pin));
JOptionPane.showMessageDialog(f, "Debit Successfully added","Information",
JOptionPane.INFORMATION_MESSAGE);
//Creating getter methods for textfields to get data of debitPanel
public String getClientName(){
return tfClient.getText().trim();
public String getBankAccount(){
return tfBankAc.getText().trim();
public String getIssuerName(){
AAYUSH KHATWADA 135 |
Page
CS4001NT Programming
return tfIssuer.getText().trim();
public int getBalanceAmount(){
String amount= tfAmt.getText().trim();
int amountBank=INVALID;
//Checking if id is empty or not
if (amount.isEmpty()){
amountBank=EMPTY;
return amountBank ;
//using try catch for exceptions
try{
amountBank= Integer.parseInt(amount);
catch(NumberFormatException e){
return amountBank;
AAYUSH KHATWADA 136 |
Page
CS4001NT Programming
public int getCardID(){
String cardText= tfCard.getText().trim();
int card= INVALID;
//Checking if textfield is empty or not
if (cardText.isEmpty()){
card=EMPTY;
return card;
//using try catch for exceptions
try{
card= Integer.parseInt(cardText);
catch(NumberFormatException e){
return card;
AAYUSH KHATWADA 137 |
Page
CS4001NT Programming
public int getPinNUmber(){
String pinText = tfPinNumber.getText().trim();
int pin= INVALID;
//Checking if textfield is empty or not
if(pinText.isEmpty()){
pin = EMPTY;
return pin;
// using try catch for exceptions
try{
pin= Integer.parseInt(pinText);
catch (NumberFormatException e){
return pin;
// Creating a method to check ID is unique or not
AAYUSH KHATWADA 138 |
Page
CS4001NT Programming
public boolean isUnique(int card){
boolean unique= true;
for ( BankCard debit: bankgui){
if (debit.getCardId()==card){
if(debit instanceof DebitCard){
JOptionPane.showMessageDialog(f, "Card ID must be unique","Error",
JOptionPane.ERROR_MESSAGE);
unique=false;
break;
return unique;
//Method for withdrawing money
public void withdrawDebit(){
String withdrawDate = getWithdrawDate();
int pinNumber = getPin();
int withdrawAmt = getWithdrawAmt();
AAYUSH KHATWADA 139 |
Page
CS4001NT Programming
int Card = getWithdrawCardID();
if(withdrawAmt == INVALID){
JOptionPane.showMessageDialog(f,"Please Enter withdraw amount","Error",
JOptionPane.ERROR_MESSAGE);
return;
if (pinNumber == INVALID){
JOptionPane.showMessageDialog(f,"Please Enter pin Number","Error",
JOptionPane.ERROR_MESSAGE);
return;
if(Card == INVALID){
JOptionPane.showMessageDialog(f,"Please Enter card ID","Error",
JOptionPane.ERROR_MESSAGE);
return;
boolean isPresent = false;
for(BankCard bg: bankgui){
AAYUSH KHATWADA 140 |
Page
CS4001NT Programming
if(bg instanceof DebitCard){
DebitCard dc = (DebitCard)bg;
if(bg.getCardId()==Card){
dc.withdraw(withdrawAmt, pinNumber, withdrawDate);
withdrawPanel.setVisible(true);
isPresent = true;
break;
if(isPresent == true)
JOptionPane.showMessageDialog(f,"Please See terminal for the message.\n"
+" \t\t\t\t\t\t\t\t THANK YOU " , "Info",JOptionPane.INFORMATION_MESSAGE);
else{
JOptionPane.showMessageDialog(f,"Incorrect cardId
","Error",JOptionPane.ERROR_MESSAGE);
return;
AAYUSH KHATWADA 141 |
Page
CS4001NT Programming
//Getter Method to abstract values from withdrawPanel TextFields
public String getWithdrawDate(){
return(withdrawalBoxYear.getSelectedItem()+"
"+withdrawalBoxMonth.getSelectedItem()+" " +
withdrawalBoxDay.getSelectedItem());
public int getPin(){
String pinNumberText = tfPin.getText().trim();
int pinNumber = INVALID;
if(pinNumberText.isEmpty()){
pinNumber = EMPTY;
//return pinNumber;
try{
pinNumber = Integer.parseInt(pinNumberText);
catch(NumberFormatException p){
if (pinNumber<=0){
AAYUSH KHATWADA 142 |
Page
CS4001NT Programming
pinNumber = INVALID;
//return pinNumber;
return pinNumber;
public int getWithdrawAmt(){
String withdrawText = tfWithdrawalAmt.getText().trim();
int withdrawAmt = INVALID;
if (withdrawText.isEmpty()){
withdrawAmt=EMPTY;
try{
withdrawAmt= Integer.parseInt(withdrawText);
catch(NumberFormatException w){
if(withdrawAmt<=0){
AAYUSH KHATWADA 143 |
Page
CS4001NT Programming
withdrawAmt =INVALID;
return withdrawAmt;
public int getWithdrawCardID(){
String cardIDText = tfCardID.getText().trim();
int Card = INVALID;
if (cardIDText.isEmpty()){
Card= INVALID;
// return Card;
try{
Card = Integer.parseInt(cardIDText);
catch(NumberFormatException c){
AAYUSH KHATWADA 144 |
Page
CS4001NT Programming
if(Card<=0){
Card = INVALID;
// return Card;
return Card;
//Method for displaying all the details of DebitPanel
public void displayDebitCard(){
boolean present = false;
for (BankCard debit: bankgui){
if(debit instanceof DebitCard){
debit.display();
JOptionPane.showMessageDialog(f,"Details Displayed Done
Successfully","Info",JOptionPane.INFORMATION_MESSAGE);
present = true;
else{
JOptionPane.showMessageDialog(f,"Debit not an
DebitCard","Error",JOptionPane.ERROR_MESSAGE);
return;
AAYUSH KHATWADA 145 |
Page
CS4001NT Programming
if(present == false){
JOptionPane.showMessageDialog(f,"Please add Debit Information First","
Error",JOptionPane.ERROR_MESSAGE);
return;
//Method to add CreditCard
public void addCreditCard(){
String creClientName = getCreClient();
String creBankAcc = getCreBankAcc();
String creIssuer = getCreIssuer();
String expirationDate = getExpirationDate();
//checking whether the textFields are empty or not
if(creClientName.isEmpty() || creBankAcc.isEmpty() || creIssuer.isEmpty()){
JOptionPane.showMessageDialog(f,"Please fill all the
boxes","Error!!",JOptionPane.ERROR_MESSAGE);
return;
}
AAYUSH KHATWADA 146 |
Page
CS4001NT Programming
int creCard = getCreCardId();
int cvc = getCvcNum();
double interestRate = getInterestRate();
int creBalanceAmount = getCreBalanceAmt();
//Checking if integers are less than 0 or not
if(creCard<=0){
creCard = INVALID;
if(interestRate<=0){
interestRate = INVALID;
if(creBalanceAmount<=0){
creBalanceAmount = INVALID;
//Checking if data are invalid and displaying suitable message if they are invalid
if(creCard ==INVALID){
JOptionPane.showMessageDialog(f,"Please enter positive number in card
Id","Error!!",JOptionPane.ERROR_MESSAGE);
AAYUSH KHATWADA 147 |
Page
CS4001NT Programming
return;
if(cvc == INVALID){
JOptionPane.showMessageDialog(f,"Please enter positive number in CVC
Number.","Error!!",JOptionPane.ERROR_MESSAGE);
return;
if(interestRate == INVALID){
JOptionPane.showMessageDialog(f,"Please enter positive and valid number
in Interest Rate.","Error!!",JOptionPane.ERROR_MESSAGE);
return;
if(creBalanceAmount == INVALID){
JOptionPane.showMessageDialog(f,"Please enter positive and valid number
in Balance Amount.","Error!!",JOptionPane.ERROR_MESSAGE);
return;
//checking if data are unique and invalid or not
AAYUSH KHATWADA 148 |
Page
CS4001NT Programming
if(creCard==INVALID&&cvc==INVALID&&interestRate==INVALID&&creBalanceAmo
unt== INVALID){
JOptionPane.showMessageDialog(f,"invalid balanceamount, CVC
number,Interest Rate or card id","Error!!",2);
return;
if(creditIsUnqiue(creCard)== true){
bankgui.add(new CreditCard(creBalanceAmount, creCard, creBankAcc,
creIssuer, creClientName, cvc, interestRate, expirationDate));
JOptionPane.showMessageDialog(f,"Credit Added Successfully for \n"+"
\t\t\t\t\t\tMr/Mrs \t"+ creClientName+"\n \t\t\t\t\t\t\t\t\t THANK YOU "
,"Information",JOptionPane.INFORMATION_MESSAGE);
//Creating getter method for credit card
public String getExpirationDate(){
AAYUSH KHATWADA 149 |
Page
CS4001NT Programming
return(expirationBoxYear.getSelectedItem()+ "" +
expirationBoxMonth.getSelectedItem()+""+ expirationBoxDay.getSelectedItem());
public String getCreClient(){
return tfCreClient.getText().trim().toUpperCase();
public String getCreIssuer(){
return tfCredIssuer.getText().trim().toUpperCase();
public String getCreBankAcc(){
return tfCreBankAcc.getText().trim().toUpperCase();
public int getCreCardId(){
String cardTxt = tfCreCardId.getText().trim();
int cardId = INVALID;
//Checking if Id is empty or not
if(cardTxt.isEmpty()){
AAYUSH KHATWADA 150 |
Page
CS4001NT Programming
cardId = EMPTY;
return cardId;
//using try catch for expections
try{
cardId = Integer.parseInt(cardTxt);
catch(Exception c){
return cardId;
public double getInterestRate(){
String rateTxt = tfInterestRate.getText().trim();
double interest = INVALID;
//Checking if InterestRate is Empty or not
if(rateTxt.isEmpty()){
interest = EMPTY;
return interest;
AAYUSH KHATWADA 151 |
Page
CS4001NT Programming
//using Try Catch for expections
try{
interest = Double.parseDouble(rateTxt);
catch(Exception i){
return interest;
public int getCvcNum(){
String cvcText = tfCVC.getText().trim();
int cvc = INVALID;
//Checking if CVC Number is Empty or not
if(cvcText.isEmpty()){
cvc = EMPTY;
//using Try Catch for expections
try{
cvc = Integer.parseInt(cvcText);
AAYUSH KHATWADA 152 |
Page
CS4001NT Programming
catch(Exception c){
return cvc;
public int getCreBalanceAmt(){
String balanceTxt = tfCreBalanceAmt.getText().trim();
int creBalanceAmt = INVALID;
//Checking if BalanceAmount is empty or not
if(balanceTxt.isEmpty()){
creBalanceAmt = EMPTY;
//using try catch for exceptions
try{
creBalanceAmt= Integer.parseInt(balanceTxt);
catch(Exception amt){
AAYUSH KHATWADA 153 |
Page
CS4001NT Programming
return creBalanceAmt;
//Creating a method to Check ID is Unqiue or not
public boolean creditIsUnqiue(int creCard){
boolean cardUnique= true;
for ( BankCard credit: bankgui){
if (credit.getCardId()==creCard){
if(credit instanceof CreditCard){
JOptionPane.showMessageDialog(f, "Card ID must be unique","Error",
JOptionPane.ERROR_MESSAGE);
cardUnique=false;
break;
return cardUnique;
//method for setCreditLimit
AAYUSH KHATWADA 154 |
Page
CS4001NT Programming
public void setCredit(){
int cardID = getCreLimitCardId();
int gracePeriod = getGracePeriod();
double creditLimit = getCreditLimit();
//checking if the textfields of setCredit are empty or not
if (cardID == INVALID || gracePeriod == INVALID|| creditLimit == INVALID){
JOptionPane.showMessageDialog(f,"Please Enter valid CardID,Grace Period
and CreditLimit","Error", JOptionPane.ERROR_MESSAGE);
return;
boolean isSet = false;
for(BankCard obj: bankgui){
if(obj instanceof CreditCard){
CreditCard dc = (CreditCard)obj;
if(obj.getCardId()==cardID){
dc.setCreditLimit(creditLimit, gracePeriod);
isSet = true;
break;
AAYUSH KHATWADA 155 |
Page
CS4001NT Programming
if(isSet == true)
JOptionPane.showMessageDialog(f,"Credit Limit set Successfully for Card
ID: "+ cardID + "\n" +"Please See terminal for the message" +"\n" + "\t
THANK YOU", "Info",JOptionPane.INFORMATION_MESSAGE);
else{
JOptionPane.showMessageDialog(f,"Incorrect cardId
","Error!!",JOptionPane.ERROR_MESSAGE);
return;
// getter method for setcreditLimit
public double getCreditLimit(){
String creditLimitTxt = tfCreditLimit.getText().trim();
double creditLimit = INVALID;
//checking if creditLimit is empty or not
AAYUSH KHATWADA 156 |
Page
CS4001NT Programming
if(creditLimitTxt.isEmpty()){
creditLimit = EMPTY;
//using try catch for exceptions
try{
creditLimit = Double.parseDouble(creditLimitTxt);
} catch(Exception l){
if(creditLimit<=0){
creditLimit = INVALID;
return creditLimit;
public int getGracePeriod(){
String graceTxt = tfGrace.getText().trim();
int gracePeriod = INVALID;
//checking if GracePeriod is empty or not
AAYUSH KHATWADA 157 |
Page
CS4001NT Programming
if(graceTxt.isEmpty()){
gracePeriod = EMPTY;
//using try catch for exceptions
try{
gracePeriod = Integer.parseInt(graceTxt);
}catch(Exception g){
if(gracePeriod<=0){
gracePeriod = INVALID;
return gracePeriod;
public int getCreLimitCardId(){
String cardIdTxt = tfsetCreditCard.getText().trim();
int cardID = INVALID;
//checking if GracePeriod is empty or not
if(cardIdTxt.isEmpty()){
cardID = EMPTY;
AAYUSH KHATWADA 158 |
Page
CS4001NT Programming
//using try catch for exceptions
try{
cardID = Integer.parseInt(cardIdTxt);
}catch(Exception set){
if(cardID <=0){
cardID = INVALID;
return cardID;
//method for cancel creditCard
public void cancelCreditCard(){
boolean cancel = false;
int cardId = getCancelCredit();
for(BankCard obj: bankgui){
if(obj instanceof CreditCard){
AAYUSH KHATWADA 159 |
Page
CS4001NT Programming
CreditCard credit = (CreditCard) obj;
if(credit.getCardId() == cardId){
cancel= true;
credit.cancleCreditCard();
break;
}if(cancel == true){
JOptionPane.showMessageDialog(f,"Credit Card has been canceled for:\n"+"
\t \t \t Card ID : "+cardId+ "\n \t\t\t\t\t\t\t\t THANKYOU","
Info",JOptionPane.INFORMATION_MESSAGE);
}else{
JOptionPane.showMessageDialog(f,"Card Id Does not
exist","Error!!",JOptionPane.ERROR_MESSAGE);
//getter method for cancelCredit
public int getCancelCredit(){
String cardTxt = tfCancelCard.getText().trim();
int cardid = INVALID;
//checking if cardID is empty or not
if(cardTxt.isEmpty()){
AAYUSH KHATWADA 160 |
Page
CS4001NT Programming
cardid = EMPTY;
//using try catch for exceptions
try{
cardid = Integer.parseInt(cardTxt);
}catch(Exception f){
if(cardid <=0){
cardid = INVALID;
return cardid;
//method to display creditCard
public void displayCreditCard(){
boolean display = false;
for (BankCard obj: bankgui){
if(obj instanceof CreditCard){
obj.display();
AAYUSH KHATWADA 161 |
Page
CS4001NT Programming
JOptionPane.showMessageDialog(f,"Details Displayed Done
Successfully","Info",JOptionPane.INFORMATION_MESSAGE);
display = true;
else{
JOptionPane.showMessageDialog(f,"Credit not an
CreditCard","Error",JOptionPane.ERROR_MESSAGE);
return;
if(display == false){
JOptionPane.showMessageDialog(f,"Please add Debit Information First","
Error",JOptionPane.ERROR_MESSAGE);
return;
public static void main(String[] args) {
new BankGUI();
}
AAYUSH KHATWADA 162 |
Page
CS4001NT Programming
AAYUSH KHATWADA 163 |
Page