Results 1 to 7 of 7

Thread: compile error

  1. #1
    dirtycash is offline Member
    Join Date
    Nov 2007
    Posts
    38
    Rep Power
    0

    Default compile error

    ....................
    Last edited by dirtycash; 12-12-2007 at 07:02 PM. Reason: question answered

  2. #2
    ShoeNinja's Avatar
    ShoeNinja is offline Senior Member
    Join Date
    Oct 2007
    Posts
    124
    Rep Power
    0

    Default

    Inside your Account class you need a constructor that handles two strings.

    Java Code:
    public Account(String email, String password){
        /* Do something with Strings.  Probably set them equal
         * to the email and password fields in the Account class.
         */
    }

  3. #3
    dirtycash is offline Member
    Join Date
    Nov 2007
    Posts
    38
    Rep Power
    0

    Default

    i have this already

    Java Code:
    public Account(String email, String pwd, int balance, ArrayList transactions) 
        {
            this.email = email;
            password = pwd;
            balance = 0;
            transactions = new ArrayList<String>();
            
        }

  4. #4
    ShoeNinja's Avatar
    ShoeNinja is offline Senior Member
    Join Date
    Oct 2007
    Posts
    124
    Rep Power
    0

    Default

    Yeah but you need a constructor with the right signature. If you are going to pass it two Strings, then you need a constructor that handles two Strings like the one I put above. It is possible and usually a good idea to have more than one constructor.

  5. #5
    dirtycash is offline Member
    Join Date
    Nov 2007
    Posts
    38
    Rep Power
    0

    Default

    so i have to create a new constructor just handling the 2 strings?
    i dont understand would it not function just the same as the one i have already?

  6. #6
    ShoeNinja's Avatar
    ShoeNinja is offline Senior Member
    Join Date
    Oct 2007
    Posts
    124
    Rep Power
    0

    Default

    Java Code:
     Account Account = new Account(email, password);
    So this is the call that you are trying to make. Since you are passing two Strings, the compiler is looking for a constructor that accepts two strings. The one that you have:

    Java Code:
    public Account(String email, String pwd, int balance, ArrayList transactions) 
        {
            this.email = email;
            password = pwd;
            balance = 0;
            transactions = new ArrayList<String>();
            
        }
    accepts more arguments than the two Strings that the compiler is looking for so it doesn't think that the method exists (and it doesn't).

    It actually would function the same as the one you already have. Look at your code again. You pass in the int balance and the ArrayList transactions but you don't actually do anything with them. You hardcode the account balance to 0 and create a new ArrayList instead of using the one that you passed.

    So just copy that code and get rid of the int and ArrayList that you are passing in.

  7. #7
    dirtycash is offline Member
    Join Date
    Nov 2007
    Posts
    38
    Rep Power
    0

Similar Threads

  1. Compile Trouble
    By adelgado0723 in forum New To Java
    Replies: 5
    Last Post: 04-21-2008, 03:02 AM
  2. How to compile an applet to an exe
    By elizabeth in forum Java Applets
    Replies: 4
    Last Post: 02-18-2008, 04:57 AM
  3. Unable to compile
    By gapper in forum New To Java
    Replies: 2
    Last Post: 01-14-2008, 05:31 PM
  4. Not able to compile
    By bugger in forum New To Java
    Replies: 2
    Last Post: 01-09-2008, 11:13 PM
  5. Compile a program
    By toby in forum New To Java
    Replies: 2
    Last Post: 07-30-2007, 10:09 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •