Implementing OOP!
Implementing OOP!
Hello! I've been learning Java now for about two months and have this personal-finance application that saves data to a csv file and can add transactions, delete, sum by periods, etc, and am currently delving into object-oriented programming! I'm reading about Abstraction, Encapsulation, Innheritance and Polymorphism and am getting it on the technical front. Now, I would like to try and make my code more OOP- if that makes sense. By doing it on a code I'm familiar with I think I will better understand it, but I'm not sure where to start!
Would anyone like to review my code and point me in the right direction to start? If I have to do some things over that's okay, originally my code was 400+ lines long but I managed to split it into classes somewhat. What suggestions do you have? Thank you very much!
I put my repo to private, so I am not confident the link works but if it doesn't and you would like to take a look, please let me know! https://github.com/De1ora/Personal-finance-OOP.git I'm a beginner at git and github and this is my first time putting the repo to private!
6 Replies
⌛
This post has been reserved for your question.
Hey @De1ora! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
Changed to public: https://github.com/De1ora/Personal-finance-OOP.git
GitHub
GitHub - De1ora/Personal-finance-OOP: Attempting to make my little ...
Attempting to make my little personal-finance application more object oriented. - GitHub - De1ora/Personal-finance-OOP: Attempting to make my little personal-finance application more object oriented.
I recommend you post an actual example of where you struggle, users will be more likely to help, when they don't have to click through 4 classes/ 400 loc.
Maybe there is a specific case that exemplifies where you struggle.
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
You apply static methods and call it through a class name well. Simple transactions through static methods work well.
Everything is for a single user using static fields.
To approach object oriented programming try to create an object directly. Consider what fields and methods can you hold there.
You are holding
public static double balance = 0.0;
inside the AccountManager
which has main().
In AccountManager
you have 4 operations to deposit, to withdraw, to display transactions according selected option - year, month, day and to exit.
You could create a class. The BankAccount
class. And to encapsulate there balance
and any other fields - name surname and other details.
And some or all your operations like - deposit, withdraw, show balance:
Then in your AccountManager in main() you can use it:
For example:
If you are interested then I know how to apply inheritance and polymorphism for your TransactionManager to calculate sum.💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.