Forums Register Login

OOP based project

+Pie Number of slices to send: Send
I am learning java and think myself as having knowledge more than basics but below intermediate level. I want to write an application where I could implement my understanding of OOP. Could you people advise me what to write considering that it should be revised/extended later at advance level?
+Pie Number of slices to send: Send
What else are you interested in? If you are interested in music, something musical. If sports, something sporty.
+Pie Number of slices to send: Send
Interested?.............Nothing. I spend my spare time in front of laptop practicing Java. I work in a bank, therefore, I could only think of something related to my workplace. If you think it is good to write it in OOP. Then here it is my understanding with basic banking.

Project in simple words.
A lot of people have various accounts in a bank i.e. current, saving & loan account, some have multiples. When program starts there is prompt for PIN for authentication. If successful, prompts selection 1-deposit, 2-withdrawal etc. else retries or quit. People make different transactions like paying to other people and even to bank itself (markup). The bank maintains balances of its customers and of itself where it stores aggregate of all deposits (liabilities), loans disbursed (assets), and also its income account (markup).

If you think it is too basic then please add something to start with.
+Pie Number of slices to send: Send
Yes, create an OO banking app.
No, that specification is good for a start; you can enhance it later.
Have you managed to implement the printing of notes through the CD drive?
+Pie Number of slices to send: Send
 

Campbell Ritchie wrote:
Have you managed to implement the printing of notes through the CD drive?


Sorry, failed to understand..
2
+Pie Number of slices to send: Send
The wife said that joke would not work.
+Pie Number of slices to send: Send
Now got it... I wish there would be a program to configure computer to do this. But in this way every programmer would be billionare
+Pie Number of slices to send: Send
 

Farrukh Nadeem wrote: . . . every programmer would be billionare

No, prices would rise into the billions because there is so much money available
+Pie Number of slices to send: Send
Have been busy on some assignments, could not start the project. Now, struck on this.
Account class created

Account class extended.
Database class to hold array of accounts

Now, trying to create account in main method, but dont get a way to this.
Failed to create array of accounts. Will appreciate if mistakes are pointed out. Thanks in advance
+Pie Number of slices to send: Send
Your DataBase constructor is called in main as no-argument constructor. But you have only defined a DataBase constructor with 1 argument; so the compiler will supply a default for you.
BTW, where is Account class ? you forgot to add it to the code shown above. There maybe other mistakes, but i didn't look closely.
+Pie Number of slices to send: Send
Edited in the original code.
+Pie Number of slices to send: Send
 

Farrukh Nadeem wrote:Edited in the original code.

No, don't do that. It makes subsequent replies look like rubbish.

I do not like the design. You have too many fields in the account class, and they can all be changed by set methods.

Never use \n unless you have been told LF is required, least of all in String#format. Use %n there.
Never use if (...) return true; else return false; Look here for the right format.
+Pie Number of slices to send: Send
My bad
I think I wont be able to write good code in the way I am learning. Have to shift away from this book (dietel's) and look somewhere else.
I shall appreciate your suggestion?
+Pie Number of slices to send: Send
Changed and little bit simplified
Account Class

CurrentAccount class

Customer class

Database class

Main method


Any suggestion now ??
+Pie Number of slices to send: Send
 

Farrukh Nadeem wrote:Any suggestion now ??


Yes.

1. A 'pin' belongs to a Customer, not an Account.
2. You are really hamstringing yourself by relying on arrays for your "database". Java has a bunch of collections that I think you'll find much more useful.
3. StopCoding (←click). I think you need to step back and understand what you want this "bank" of yours to do before you write one more line of Java code. Right now you're obsessed with nuts and bolts, and you need to see the bigger picture. You might also find the WhatNotHow page worth reading.

HIH

Winston
+Pie Number of slices to send: Send
Also the style could do with improvements. There are several conventions about braces (ond suggestion here), but I know of none which would have a whole method as one line.
Also look at this style guide, where you will find a better way to write the method about PINs.
+Pie Number of slices to send: Send
 

Also the style could do with improvements. There are several conventions about braces (ond suggestion here), but I know of none which would have a whole method as one line.
Also look at this style guide, where you will find a better way to write the method about PINs.


Did on purpose to feel the code shorter for you, although I follow general practice. I like the reference page, will follow it.

StopCoding.... I think you need to step back and understand what you want this "bank" of yours to do before you write one more line of Java code


Stopped.. My Bigger Picture is to write full fledged working Banking Application. Although it may take years.
Thats why I started it at a very basic level. If you still thinks I am overdoing this. then do tell me. What I understood from WhatNotHow is that I should write down each and every scenario in which my stripped down classes could work along with corner cases in pseudo code or plain English.

Please let me know if I am still going astray.
Thanks for the guidance.
+Pie Number of slices to send: Send
 

Farrukh Nadeem wrote: . . . Did on purpose to feel the code shorter for you, . . .

Don't. You are not printing millions of lines on paper, but showing dozens of lines on screen. Always go for legibility rather than length

Stopped.. . . .

Stay stopped until you have worked out what the application should do, as Winston said.
+Pie Number of slices to send: Send
 

Farrukh Nadeem wrote:What I understood from WhatNotHow is that I should write down each and every scenario in which my stripped down classes could work along with corner cases in pseudo code or plain English.


Actually, you should do it before you have any classes to strip down. And it's not meant to be absolutely exhaustive, but you should have a clear idea of what you want to do before you start to code (because code is all about how).

Winston
+Pie Number of slices to send: Send
 

you should do it before you have any classes to strip down. And it's not meant to be absolutely exhaustive.


Please elaborate a little bit more, would be grateful for an example. I want to grasp it completely before going to drawing board again.
Thank you.
+Pie Number of slices to send: Send
 

Farrukh Nadeem wrote:Please elaborate a little bit more, would be grateful for an example. I want to grasp it completely before going to drawing board again.


Well, it'll depend on your project but, for example: What does an Account do? Why is it there? What is its purpose?

If I remember my accounting right (and going partly from Wikipedia's description), it might go something like this:

"A bank account is a record of financial transactions between a Customer and a Bank, usually described in terms of the effect on the Bank's liability to the Customer. Depending on the type of account, transactions can take the form of cheques, direct (teller) transactions, standing orders or ATM activity, and the account keeps a running 'balance' (again, indicated in terms of the bank's liability). The general idea of an account is that it acts as secure storage for a Customer's money, so the pattern is usually that the Customer first deposits money and can then withdraw against it; but some accounts may also allow 'overdrafts', or even work as lines of credit, where the Customer pays interest on any outstanding debt. Savings accounts usually pay interest on balances kept above a certain limit, but in general do not allow overdrafts and may also impose restrictions on the number of transactions allowed."

Do you follow? The above describes what an account does, not how it does it - and my apologies to any accounting bods out there who can probably do it much better. Did you also notice that not once was a single Java class mentioned? This sort of stuff should generally be done before you write one line of Java code.

Do you also see why I said that a 'pin' has nothing to do with an Account?

HIH

Winston
+Pie Number of slices to send: Send
Very much Correct. The example shows what are class properties (fields) and behavior (methods) and what are its loopholes (where we need to place exceptions). Now, it is up to my need what fields, methods I want to use in the class and place plugs where something could go wrongs in worst case scenarios. Correct me if I am going wrong.

+Pie Number of slices to send: Send
 

Farrukh Nadeem wrote:Very much Correct. The example shows what are class properties (fields) and behavior (methods) and what are its loopholes (where we need to place exceptions). Now, it is up to my need what fields, methods I want to use in the class and place plugs where something could go wrongs in worst case scenarios. Correct me if I am going wrong.


No, that sounds about right; but you should be doing the above for your entire Bank scenario before you write ANY code.

I get the feeling that your mind is still leaping ahead to what the code (or the class) is going to look like, and at this stage it's simply not important. Describe what a Bank does, not how you're going to code it in Java.

WhatNotHow (←click).

Winston
+Pie Number of slices to send: Send
Ok...Below will be the function of a Banking App.

Bank...a secure custodian of money of its Customers Maintaining various Accounts as following:
Current Account -> Where bank charges a penalty if the balance goes below certain level. Keeps checks on balances not to go below zero. No transaction limit.
Saving Account -> Where bank pays interest on balances either on daily basis or month end balances. Keeps checks on balances not to go below zero. Impose transaction limit.
Loan Account -> Where bank earns profit according to the amount withdrawn (overdraft). Balance always negative or zero.
Bank Income Account -> Where all penalties & interest earned are saved.
Bank Expense Account -> Where all expenses (interest paid) are saved.
Bank Asset Account -> Where consolidated figures of Loan Accounts are saved.
Bank Liability Account -> Where consolidated figures of Current & Saving Accounts are saved.

Bank saves all Transaction History, Accounts & Customers Personal information in a DataBase.
Customers operate accounts through Tellers, Cheques, ATM etc after verification. Customers pay amounts either to other people or bank.
At the instruction of Customers, Bank issues instruments (demand draft, pay orders, wire transfers etc.) to other people or other bank.

Above is the brief function of a typical bank.
Am I going right and do I miss something? If sufficient then please advise future course of action.
+Pie Number of slices to send: Send
I think my queries are too much for you people. I regret it.
+Pie Number of slices to send: Send
 

Farrukh Nadeem wrote:I think my queries are too much for you people. I regret it.


Not at all. I can't speak for everyone, but I simply missed your response. We're all volunteers here, Farrukh; and I've been away on family business.

I would say that your previous post is a good start. Now, you need to go through each entity in turn and describe what it does in more detail. In the old days we used to call that part the "business" or "process" analysis, because it describes the processes that a Bank has to deal with. It's also likely to provide you with a lot of the methods for your classes.

Design is NOT simple; and if this was a real system, you'd probably have done at least six months of this sort of stuff before the first Java developer got involved (possibly more). For a classroom exercise, you do have to get down to coding at some point; just not straight away.

HIH

Winston
I've been selected to go to the moon! All thanks to this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 2846 times.
Similar Threads
how to use c/cpp code in java??
Search function?
overloading
Object, Aspect, and Services Oriented Programming
Why we are not allowed to declare a broader exception while overriding
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 00:25:58.