OOPS Programming Concept: Bank Account Simulation Program in Java with Inheritance and Encapsulation
VerifiedAdded on 2023/04/25
|10
|1366
|278
AI Summary
In this project we will discuss about OOPS programming concept and below are the summaries point:-
Bank account simulation program developed in Java with OOPS concepts like inheritance and encapsulation.
The program allows adding customers, performing deposits, withdrawals, and overdrafts.
Different classes are utilized, including a base class (BankAccount) and a child class (CheckingAccount).
Contribute Materials
Your contribution can guide someone’s learning journey. Share your
documents today.
Running head: OOPS PROGRAMMING CONCEPT
OOPS Programming Concept
Name of the Student
Name of the University
Authors note
OOPS Programming Concept
Name of the Student
Name of the University
Authors note
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
1OOPS PROGRAMMING CONCEPT
Introduction
This project is developed in order to simulate bank transactions such as adding a
customer with their first and last name, account id, withdrawal and overdraft etc. Different
methods and constructors are used for completing the above mentioned functionalities are
implemented. This project includes the simple functionalities such as adding a user, deposit
money, withdrawal, overdraft. Different section of this report consist of discussion about the
stages through which the program was developed and tested. In the project, as mentioned the
Bankaccount.java is declared as the base class or the parent class. Another class
CheckingAccount I is the child class that extends the base class to access the data and
methods from the parent class through using the parent class object.
Bank account simulation program in Java
In order to complete the bank account simulation program concepts of java
inheritance, encapsulation, constructors are used. In addition to that, the use of the getter and
setters for assigning and retrieving the stored values are also utilized in the different sections
of application. The concepts of super and sub class are utilized in order to call and get the
access parent class objects from the child class and vice versa. In this project most of the
operations are dependent on the input from the user. Input from the users are of mainly
double and string type. After gettinng the input from the user, different methods and
constructors are called in order to carry out various operations on these inputs to get the
required result.
Completed program
BankAccount.java
/*
Introduction
This project is developed in order to simulate bank transactions such as adding a
customer with their first and last name, account id, withdrawal and overdraft etc. Different
methods and constructors are used for completing the above mentioned functionalities are
implemented. This project includes the simple functionalities such as adding a user, deposit
money, withdrawal, overdraft. Different section of this report consist of discussion about the
stages through which the program was developed and tested. In the project, as mentioned the
Bankaccount.java is declared as the base class or the parent class. Another class
CheckingAccount I is the child class that extends the base class to access the data and
methods from the parent class through using the parent class object.
Bank account simulation program in Java
In order to complete the bank account simulation program concepts of java
inheritance, encapsulation, constructors are used. In addition to that, the use of the getter and
setters for assigning and retrieving the stored values are also utilized in the different sections
of application. The concepts of super and sub class are utilized in order to call and get the
access parent class objects from the child class and vice versa. In this project most of the
operations are dependent on the input from the user. Input from the users are of mainly
double and string type. After gettinng the input from the user, different methods and
constructors are called in order to carry out various operations on these inputs to get the
required result.
Completed program
BankAccount.java
/*
2OOPS PROGRAMMING CONCEPT
package bankaccount;
/**
*
*
*/
public class CheckingAccount extends BankAccount{
double interstrate;
BankAccount bn=new BankAccount();
// @Override
// public int getAccountID() {
// return super.getAccountID(); //To change body of generated methods, choose
Tools | Templates.
// }
void processWithdrawal()
{
bn.balance=-(balance+30);
System.out.println("This is balance after overdraft");
System.out.println(bn.balance);
}
void displayAccount()
{
System.out.println("Following is the Details of the account");
System.out.println( "First name :"+bn.getFirtsname());
System.out.println("Last name :"+bn.getLastname());
System.out.println("Account ID :"+bn.getAccountID());
System.out.println("Available balance afetr overdraft :"+bn.getBalance());
package bankaccount;
/**
*
*
*/
public class CheckingAccount extends BankAccount{
double interstrate;
BankAccount bn=new BankAccount();
// @Override
// public int getAccountID() {
// return super.getAccountID(); //To change body of generated methods, choose
Tools | Templates.
// }
void processWithdrawal()
{
bn.balance=-(balance+30);
System.out.println("This is balance after overdraft");
System.out.println(bn.balance);
}
void displayAccount()
{
System.out.println("Following is the Details of the account");
System.out.println( "First name :"+bn.getFirtsname());
System.out.println("Last name :"+bn.getLastname());
System.out.println("Account ID :"+bn.getAccountID());
System.out.println("Available balance afetr overdraft :"+bn.getBalance());
3OOPS PROGRAMMING CONCEPT
}
}
CheckingAccount.Java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package bankaccount;
public class CheckingAccount extends BankAccount{
double interstrate;
BankAccount bn=new BankAccount();
// @Override
// public int getAccountID() {
// return super.getAccountID(); //To change body of generated methods, choose
Tools | Templates.
// }
void processWithdrawal()
{
bn.balance=-(balance+30);
System.out.println(bn.balance);
}
void displayAccount()
{
System.out.println(bn.getFirtsname());
System.out.println(bn.getLastname());
System.out.println(bn.getAccountID());
System.out.println(bn.getBalance());
}
}
CheckingAccount.Java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package bankaccount;
public class CheckingAccount extends BankAccount{
double interstrate;
BankAccount bn=new BankAccount();
// @Override
// public int getAccountID() {
// return super.getAccountID(); //To change body of generated methods, choose
Tools | Templates.
// }
void processWithdrawal()
{
bn.balance=-(balance+30);
System.out.println(bn.balance);
}
void displayAccount()
{
System.out.println(bn.getFirtsname());
System.out.println(bn.getLastname());
System.out.println(bn.getAccountID());
System.out.println(bn.getBalance());
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
4OOPS PROGRAMMING CONCEPT
}
}
}
}
5OOPS PROGRAMMING CONCEPT
Program execution Screenshots
Screenshot for adding a customer
Screenshot for depositing a value
Getting the over draft and final account balance
Program execution Screenshots
Screenshot for adding a customer
Screenshot for depositing a value
Getting the over draft and final account balance
6OOPS PROGRAMMING CONCEPT
Reflection questions
Project Purpose: The purpose of the project is to develop a java program with two classes
that will help in simulating the bank transactions.
Algorithm used: In this project the inheritance is used and the user input choice based
algorithm is utilized. The complete algorithm is given n below;
Program inputs: The user needs to enter their choices according to the prompted options in
order to go through the functionalities of the program.
Program outputs: For every stage the user can select one the options among the display
account details, account summary.
Program limitations: According to the initial requirement and specifications that program is
completed. As the program is Only CLI based program this can be extended to have GUI.
Program errors: Initially while working with the getter and setter methods there were some
errors aroused which were later resolved through some research on google and other
programming communities.
Reflection questions
Project Purpose: The purpose of the project is to develop a java program with two classes
that will help in simulating the bank transactions.
Algorithm used: In this project the inheritance is used and the user input choice based
algorithm is utilized. The complete algorithm is given n below;
Program inputs: The user needs to enter their choices according to the prompted options in
order to go through the functionalities of the program.
Program outputs: For every stage the user can select one the options among the display
account details, account summary.
Program limitations: According to the initial requirement and specifications that program is
completed. As the program is Only CLI based program this can be extended to have GUI.
Program errors: Initially while working with the getter and setter methods there were some
errors aroused which were later resolved through some research on google and other
programming communities.
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
7OOPS PROGRAMMING CONCEPT
Lessons learned
In this project, we learned about the use of getter and setter methods. The getter and
setter methods provide a unified control mechanism for some specific fields or variables
which are also initialized. In this way, the validation and debugging of the classes become
much easier.
In the case of inheritance, the constructor of the subclass/child class is invoked
whenever an object of the subclass is created. Furthermore, as the child class inherits all the
methods, constructors and variables thus the default constructor of the superclass is also
called by the child object.
Thus it can be stated that in java the class objects are created in the top-down
approach. The constructor of the superclass also can be invoked explicitly by utilizing the
super keyword for the superclass object. In this case, it is important to remember that this
should be the first statement inside the constructor. super keyword denotes to the superclass
in the program structure, nearly above the calling class in the program hierarchy.
Conclusion
While developing the application the methods getters and setters are very helpful in
the encapsulation process of the variables and methods. With this method the complexity in
taking input from the user’s end becomes increases. The reason behind this can be stated as
the methods took a bit more time to implement and pass variables to the subclasses from the
superclass. According to the requirement, the processWithdrawal(), displayAccount() are
also implemented in order to display the details of the customers or process the withdrawal
amount according to the user input. With the use of the modularity the complete program is
divided into multiple small methods and classes. Integration of these methods and classes are
then required for carrying out the overall desired functionality.
Lessons learned
In this project, we learned about the use of getter and setter methods. The getter and
setter methods provide a unified control mechanism for some specific fields or variables
which are also initialized. In this way, the validation and debugging of the classes become
much easier.
In the case of inheritance, the constructor of the subclass/child class is invoked
whenever an object of the subclass is created. Furthermore, as the child class inherits all the
methods, constructors and variables thus the default constructor of the superclass is also
called by the child object.
Thus it can be stated that in java the class objects are created in the top-down
approach. The constructor of the superclass also can be invoked explicitly by utilizing the
super keyword for the superclass object. In this case, it is important to remember that this
should be the first statement inside the constructor. super keyword denotes to the superclass
in the program structure, nearly above the calling class in the program hierarchy.
Conclusion
While developing the application the methods getters and setters are very helpful in
the encapsulation process of the variables and methods. With this method the complexity in
taking input from the user’s end becomes increases. The reason behind this can be stated as
the methods took a bit more time to implement and pass variables to the subclasses from the
superclass. According to the requirement, the processWithdrawal(), displayAccount() are
also implemented in order to display the details of the customers or process the withdrawal
amount according to the user input. With the use of the modularity the complete program is
divided into multiple small methods and classes. Integration of these methods and classes are
then required for carrying out the overall desired functionality.
8OOPS PROGRAMMING CONCEPT
In addition to that, different other control statements are also utilized in the different
segments of this application. As required for the project the balance variable is also initialized
with the value zero and later on using the setter method the users can also modify the value of
this variable through the keyboard input.
In addition to that, different other control statements are also utilized in the different
segments of this application. As required for the project the balance variable is also initialized
with the value zero and later on using the setter method the users can also modify the value of
this variable through the keyboard input.
9OOPS PROGRAMMING CONCEPT
Bibliography
Baesens, B., Backiel, A., & Vanden Broucke, S. (2015). Beginning Java programming: the
object-oriented approach. John Wiley & Sons.
Chen, J. Y., & Lee, G. C. (2016). From Greenfoot to Java: study of students’ object-oriented
design ability and Java programming skills. ISSEP 2016, 43.
Joyce, D. T., & Weems, C. (2016). Object-oriented data structures using Java. Jones &
Bartlett Publishers.
McMaster, K., Sambasivam, S., Rague, B., & Wolthuis, S. (2017). Java vs. Python Coverage
of Introductory Programming Concepts: A Textbook Analysis. Information Systems
Education Journal, 15(3), 4.
Xinogalos, S. (2015). Object-oriented design and programming: an investigation of novices’
conceptions on objects and classes. ACM Transactions on Computing Education
(TOCE), 15(3), 13.
Bibliography
Baesens, B., Backiel, A., & Vanden Broucke, S. (2015). Beginning Java programming: the
object-oriented approach. John Wiley & Sons.
Chen, J. Y., & Lee, G. C. (2016). From Greenfoot to Java: study of students’ object-oriented
design ability and Java programming skills. ISSEP 2016, 43.
Joyce, D. T., & Weems, C. (2016). Object-oriented data structures using Java. Jones &
Bartlett Publishers.
McMaster, K., Sambasivam, S., Rague, B., & Wolthuis, S. (2017). Java vs. Python Coverage
of Introductory Programming Concepts: A Textbook Analysis. Information Systems
Education Journal, 15(3), 4.
Xinogalos, S. (2015). Object-oriented design and programming: an investigation of novices’
conceptions on objects and classes. ACM Transactions on Computing Education
(TOCE), 15(3), 13.
1 out of 10
Your All-in-One AI-Powered Toolkit for Academic Success.
+13062052269
info@desklib.com
Available 24*7 on WhatsApp / Email
Unlock your academic potential
© 2024 | Zucol Services PVT LTD | All rights reserved.