Sorry guys i need to delet this code
Printable View
Sorry guys i need to delet this code
I have changed this section but i am still not sure how to return the new account i have add.
Code Java:public BankAccountOutputVO createNewCurrentAccount(String name, double amount, double overdraftLimit) { CurrentAccount acc = new CurrentAccount(name, amount, overdraftLimit); return acc; }
Does you new code work ok?
use the highlight=java tags or the code tags so it is easier to read your code. I may be able to help you if it is easier to read.
yes the new code does not come with any errors but i am not sure how to return the object back. i am sorry but i not sure which tag that aussiemcgr is talking about.
I didn't look at the code in detail at all, but I see this:
//THIS IS THE ERROR I AM GETTING "Cannot instantiate the type BankAccount"
BankAccount acc = new BankAccount(name, amount);
...
public abstract class BankAccount {
...
If the class is abstract, you can't create an object of that class. You need to extend that class and implement the abstract methods first.
Can you show the code where you are having this problem?Quote:
i am not sure how to return the object back
Code :import java.util.List; public class BankManager implements _BankManager { public BankAccountOutputVO ViewAccountSummary(String accountNumber) { // TODO Auto-generated method stub return null; } public BankAccountOutputVO closeAcount(String accountNumber) { // TODO Auto-generated method stub return null; } public BankAccountOutputVO createNewCurrentAccount(String name, double amount, double overdraftLimit) { CurrentAccount acc = new CurrentAccount(name, amount, overdraftLimit); // i am getting the error here. return accl; } public BankAccountOutputVO createNewSavingsAccount(String name, double amount) { // TODO Auto-generated method stub return null; } public List<BankAccountOutputVO> listAllAccounts() { // TODO Auto-generated method stub return null; } public BankAccountOutputVO makeDeposit(String accountNumber, double amount) { // TODO Auto-generated method stub return null; } public BankAccountOutputVO makeWithdrawal(String accountNumber, double amount) { // TODO Auto-generated method stub return null; } }
What is the error? Please post full text.Quote:
i am getting the error here.
This is the error from the compile
"Type mismatch: cannot convert from CurrentAccount to BankAccountOutputVO" the thing i am not sure about is what to call back. Thank you for ur help
Please post full text.
Please copy full text of error message and paste it here. Here is a sample:
Code :TestSorts.java:138: cannot find symbol symbol : variable var location: class TestSorts var = 2; ^
i am using eclipse and there there is not more information. thanks you.
For tags, parse your code with the highlight wrap, put this before your code (I'm going to use * to represent [ and ] since I dont know how to stop parsing) *highlight=java* and this after your code */highlight*. And your code will look nice and colorful.
Lets break it down. The error is specificially occuring here:
Code java:public BankAccountOutputVO createNewCurrentAccount(String name, double amount, double overdraftLimit) { CurrentAccount acc = new CurrentAccount(name, amount, overdraftLimit); // i am getting the error here. return accl; }
You should be getting a problem when you are trying to return accl, seeing how that variable doesnt exist.
However, I assume you mean to return acc, so the reason your getting this issue is because CurrentAccount is a BankAccount and BankAccountOutputVO is not. You are saying you want to return a BankAccountOutputVO object, but you are attempting to return a CurrentAccount object. By the looks of it, a BankAccount Object is just a BankAccountOutputVO Object with added methods. I'm not sure about your assignment specificiations, but can you make BankAccount extend BankAccountOutputVO? I actually dont even see the point in having any BankAccountOutputVO Objects.
we got given the bankaccounvo class. i am not sure if we can extended the class because the bankaccounvo class is a final class, and we got told not to edit this class. the code is not an assigment it be given to help us learn java.
sorry i tried to call the BANKACCOUNTVO but the also gave with the same error
Why not have that method create and return what it is supposed to:
Code :public BankAccountOutputVO createNewCurrentAccount(String name, double amount, double overdraftLimit) { BankAccountOutputVO acc = new BankAccountOutputVO(.....); return acc; }
Hi i tried to do that but i still get i null pointer exception. the same error as before thank you for your help.
Can you post the full error text and the code that is causing it?
before you said the error was a mismatch, now you say its a null pointer exception.
One is at compile time the other at execution time.
Thanks Guys for you help i managed to solve that problem. I was wondering how to save my new accounts in a list so i could manage these accounts. thank you.
Is this problem solved?
If so, please mark this thread as solved.
one of the problem is solved i am just trying to create an array list to store all the account if you could give me some addvice on these. Thanks
The are many code examples online. Use a Search to find some.
Basically you create an ArrayList object and use its add() method to add objects to it.
Thanks for all your help. i started to understand the basics of java programming now.
Hi i have written this code but i am not sure how to add the imformation from the interface to the arraylist
Code Java:package com.fdm.bank; import java.util.ArrayList; public class Storage { private ArrayList<Integer> CurrentAccount = new ArrayList<Integer>(); public void add(int number) { CurrentAccount.add(number); } public ArrayList<Integer> getList() { return CurrentAccount; } }
Code Java:package com.fdm.bank; import java.util.ArrayList; import java.util.List; public class BankManager implements _BankManager { public BankAccountOutputVO ViewAccountSummary(String accountNumber) { // TODO Auto-generated method stub return null; } public BankAccountOutputVO closeAcount(String accountNumber) { // TODO Auto-generated method stub return null; } public BankAccountOutputVO createNewCurrentAccount(String name, double amount, double overdraftLimit) { // long accNumber = BankAccount.randomAccNo(); CurrentAccount currentAcc = new CurrentAccount(name, amount, overdraftLimit); BankAccountOutputVO bao = new BankAccountOutputVO(currentAcc .getAccountNumber() + "", currentAcc.getAccountType(), currentAcc.getName(), currentAcc.getOverdraft() + "", currentAcc.getAmount() + "", true); return bao; } public BankAccountOutputVO createNewSavingsAccount(String name, double amount) { SavingAccount savingAcc = new SavingAccount(name, amount, amount); BankAccountOutputVO bao = new BankAccountOutputVO(savingAcc .getAccountNumber() + "", savingAcc.getAccountType(), savingAcc.getName(), savingAcc.getOverdraft() + "", savingAcc.getAmount() + "", true); return bao; } public List<BankAccountOutputVO> listAllAccounts() { Storage BankAccount = new Storage(); BankAccount.add(5); ArrayList<Integer> list = BankAccount.getList(); for (Integer counter : list) { System.out.println(counter); } return null; } public BankAccountOutputVO makeDeposit(String accountNumber, double amount) { // TODO Auto-generated method stub return null; } public BankAccountOutputVO makeWithdrawal(String accountNumber, double amount) { // TODO Auto-generated method stub return null; } }
Can you explain where your problem is?Quote:
how to add the imformation from the interface to the arraylist
What is the information?
what is the interface?