LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   inheretance and ArrayList in java ..i want to know the mistake in my code (https://www.linuxquestions.org/questions/programming-9/inheretance-and-arraylist-in-java-i-want-to-know-the-mistake-in-my-code-943410/)

4four 05-05-2012 10:37 AM

inheretance and ArrayList in java ..i want to know the mistake in my code
 
hello every body

i am tring to solve this problem ,but i think there is smth wrong
cna any body help me

Quote:

Write a program client program that deals with different classes:
1. BankAccount class similar to the one in textbook but with additional data member accountName a string.
2. BranchBank class which consists of an arraylist of element of type BankAccount (should be protected) and an IdBranch an integer identifying the branch id. This class should contain the class constructor which reads from a file bank the branch id and the information about the accounts to be created in this branch. This class should have the following methods: searchAccount which takes as a parameter an account name and returns the corresponding BankAccount. addAccount which will add a new account in the branch.

this is my code

dwhitney67 05-05-2012 10:45 AM

Really? I did not see the following in your requirements.
Code:

public class BranchBank extends BankAccount{
Ask yourself if this statement rings true: A BranchBank "is a" BankAccount.

A BranchBank contains one or more BankAccounts... keyword being "contains".


Quote:

Originally Posted by 4four (Post 4671007)
hello every body

i am tring to solve this problem ,but i think there is smth wrong
cna any body help me

If you need help with spelling words, don't hesitate to ask.

4four 05-05-2012 12:54 PM

Quote:

Originally Posted by dwhitney67 (Post 4671012)
Really? I did not see the following in your requirements.
Code:

public class BranchBank extends BankAccount{
Ask yourself if this statement rings true: A BranchBank "is a" BankAccount.

A BranchBank contains one or more BankAccounts... keyword being "contains".



If you need help with spelling words, don't hesitate to ask.

it is not correct but accorrding to this statement
Quote:

BranchBank class which consists of an arraylist of element of type BankAccount (should be protected)
I think that I have to write it like this

dugan 05-05-2012 01:30 PM

I think you misunderstood.

Quote:

BranchBank class which consists of an arraylist of element of type BankAccount (should be protected) and an IdBranch an integer...
Code:

public class BranchBank
{
    // dot dot dot...
    protected ArrayList<BankAccount> accounts;
}


4four 05-05-2012 02:06 PM

Quote:

Originally Posted by dugan (Post 4671129)
I think you misunderstood.



Code:

public class BranchBank
{
    // dot dot dot...
    protected ArrayList<BankAccount> accounts;
}


aha. i want to write like this but it is correct to write this statement
protected ArrayList<BankAccount> accounts;
inside BranchBank without using inheretance

4four 05-05-2012 02:10 PM

now i will modify it .what about the rest of the code?

dugan 05-05-2012 02:10 PM

Quote:

what about the rest of the code?
It's your homework, not ours. We're not going to write the rest of the code for you.

If that's not what you meant then please clarify.

4four 05-05-2012 02:19 PM

thanx

4four 05-05-2012 02:44 PM

Quote:

Originally Posted by dugan (Post 4671149)
It's your homework, not ours. We're not going to write the rest of the code for you.

If that's not what you meant then please clarify.

you misunderstand me. I mean can you help me to correct my mistake.
beause my solution to other tasks will be wrong if these codes are wrong.
I were doing my best.

dugan 05-05-2012 03:27 PM

You could start by wrapping your code in CODE tags rather than QUOTE tags, so that we can read it.

4four 05-05-2012 03:39 PM

.....

dugan 05-05-2012 03:42 PM

Looks like you got it.

4four 05-05-2012 03:44 PM

it is too long problem.I am waiting for you reply.thanks so much

4four 05-05-2012 03:45 PM

Quote:

Originally Posted by dugan (Post 4671177)
Looks like you got it.

What?!:D?

dugan 05-05-2012 03:46 PM

Uhm, yeah, it looks like you've completed the requirements that you posted.


All times are GMT -5. The time now is 03:30 AM.