Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Page 1 of 3 123 LastLast
Results 1 to 25 of 51

Thread: Help with programe please

  1. #1
    Junior Member
    Join Date
    Aug 2010
    Posts
    26
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Red face Help with programe please

    Sorry guys i need to delet this code
    Last edited by Newtojava; August 18th, 2010 at 08:30 AM.


  2. #2
    Junior Member
    Join Date
    Aug 2010
    Posts
    26
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Re: Help with programe please

    I have changed this section but i am still not sure how to return the new account i have add.
    public BankAccountOutputVO createNewCurrentAccount(String name,
    			double amount, double overdraftLimit)
    	{
    		CurrentAccount acc = new CurrentAccount(name, amount, overdraftLimit);
    		return acc;
    	}
    Last edited by helloworld922; August 6th, 2010 at 09:00 AM.

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Help with programe please

    Does you new code work ok?

  4. #4
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default Re: Help with programe please

    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.

  5. #5
    Junior Member
    Join Date
    Aug 2010
    Posts
    26
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Re: Help with programe please

    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.

  6. #6
    Member
    Join Date
    Jul 2010
    Posts
    45
    Thanks
    10
    Thanked 3 Times in 3 Posts

    Default Re: Help with programe please

    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.

  7. #7
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Help with programe please

    i am not sure how to return the object back
    Can you show the code where you are having this problem?

  8. #8
    Junior Member
    Join Date
    Aug 2010
    Posts
    26
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Re: Help with programe please

     
    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;
    	}
     
    }

  9. #9
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Help with programe please

    i am getting the error here.
    What is the error? Please post full text.

  10. #10
    Junior Member
    Join Date
    Aug 2010
    Posts
    26
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Re: Help with programe please

    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

  11. #11
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Help with programe please

    Please post full text.
    Please copy full text of error message and paste it here. Here is a sample:
    TestSorts.java:138: cannot find symbol
    symbol  : variable var
    location: class TestSorts
             var = 2;
             ^

  12. #12
    Junior Member
    Join Date
    Aug 2010
    Posts
    26
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Re: Help with programe please

    i am using eclipse and there there is not more information. thanks you.

  13. #13
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default Re: Help with programe please

    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:
    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.

  14. #14
    Junior Member
    Join Date
    Aug 2010
    Posts
    26
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Re: Help with programe please

    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
    Last edited by Newtojava; August 5th, 2010 at 10:51 AM.

  15. #15
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Help with programe please

    Why not have that method create and return what it is supposed to:
    public BankAccountOutputVO createNewCurrentAccount(String name,
                double amount, double overdraftLimit)
        {
            BankAccountOutputVO acc = new BankAccountOutputVO(.....);
             return acc;
        }

  16. #16
    Junior Member
    Join Date
    Aug 2010
    Posts
    26
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Re: Help with programe please

    Hi i tried to do that but i still get i null pointer exception. the same error as before thank you for your help.
    Last edited by Newtojava; August 6th, 2010 at 04:05 AM.

  17. #17
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Help with programe please

    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.

  18. #18
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Help with programe please

    Quote Originally Posted by aussiemcgr View Post
    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.
    To ignore all parsing, you can use the [noparse] tag (lol, I had to surround this with the noparse tag)

    how to use the highlight tag:

    [highlight=Java]
    // code goes in here
    [/highlight]

    what it looks like:

    // code goes in here

  19. #19
    Junior Member
    Join Date
    Aug 2010
    Posts
    26
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Re: Help with programe please

    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.

  20. #20
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Help with programe please

    Is this problem solved?
    If so, please mark this thread as solved.

  21. #21
    Junior Member
    Join Date
    Aug 2010
    Posts
    26
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Re: Help with programe please

    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

  22. #22
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Help with programe please

    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.

  23. The Following User Says Thank You to Norm For This Useful Post:

    Newtojava (August 10th, 2010)

  24. #23
    Junior Member
    Join Date
    Aug 2010
    Posts
    26
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Re: Help with programe please

    Thanks for all your help. i started to understand the basics of java programming now.

  25. #24
    Junior Member
    Join Date
    Aug 2010
    Posts
    26
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Re: Help with programe please

    Hi i have written this code but i am not sure how to add the imformation from the interface to the arraylist

    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;
    	}
     
    }
    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;
    	}
     
    }

  26. #25
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Help with programe please

    how to add the imformation from the interface to the arraylist
    Can you explain where your problem is?
    What is the information?
    what is the interface?

Page 1 of 3 123 LastLast