Results 1 to 8 of 8
  1. #1
    Sandra is offline Member
    Join Date
    Sep 2013
    Posts
    4
    Rep Power
    0

    Default Need help with add method in Array

    public class EntityModel {

    /**
    * The model can only store up to MAX_RECORDS
    */
    public static final int MAX_RECORDS = 10000;
    /**
    * The array storing the records
    */
    protected Entity[] allRecords;
    /**
    * The number of records being stored
    */
    protected int totalRecords;
    /**
    * The current record index. The main purpose of the class is to
    * maintain this.
    */
    protected int current;
    /**
    * A count of the number of records that have been marked for deletion
    */
    protected int delRecCount;

    // CONSTRUCTORS
    /**
    * Creates a EntityModel capable of storing <var>MAX_RECORDS</var> using
    * an array
    * <p>
    * The current position is set to -1 (undefined)
    *
    * Creates the array
    * <Initialises the totalRecords to zero
    * Initialises the delRecCount to zero
    * Sets current to be -1
    *
    *
    */
    public EntityModel() {
    //TODO
    }
    // INSERTING RECORDS
    public Entity add(Entity entity) {
    //TODO
    return null; //remove or modify this line as needed
    }

  2. #2
    AndrewM16921 is offline Senior Member
    Join Date
    Jan 2009
    Location
    NJ, USA
    Posts
    263
    Rep Power
    6

    Default Re: Need help with add method in Array

    Your code is very difficult to read. Please surround it with [code][/code] tags.

  3. #3
    Sandra is offline Member
    Join Date
    Sep 2013
    Posts
    4
    Rep Power
    0

    Default Re: Need help with add method in Array

    How to create add metod?

    public class EntityModel {

    public static final int MAX_RECORDS = 10000;
    protected Entity[] allRecords;
    protected int totalRecords;
    protected int current;
    public EntityModel() {
    //TODO
    }
    // INSERTING RECORDS
    public Entity add(Entity entity) {
    //TODO
    return null; //remove or modify this line as needed
    }

  4. #4
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,060
    Rep Power
    6

    Default Re: Need help with add method in Array

    So what's your question? You haven't told us what the add method is supposed to do. What you have there is perfectly valid code that just happens to do nothing.
    Get in the habit of using standard Java naming conventions!

  5. #5
    Sandra is offline Member
    Join Date
    Sep 2013
    Posts
    4
    Rep Power
    0

    Default Re: Need help with add method in Array

    This method adds the entity to the array. It will need to
    * increment the totalRecords counter and also check if the entity being
    * added is marked for deletion

  6. #6
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,060
    Rep Power
    6

    Default Re: Need help with add method in Array

    Okay. What part of that don't you understand?
    Get in the habit of using standard Java naming conventions!

  7. #7
    Sandra is offline Member
    Join Date
    Sep 2013
    Posts
    4
    Rep Power
    0

    Default Re: Need help with add method in Array

    i created before Address Class,Student Class,Entity Class and tested already...The next step a EntityModel, i don't know how to start method adds with Array

  8. #8
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,753
    Rep Power
    5

    Default Re: Need help with add method in Array

    Quote Originally Posted by Sandra View Post
    i don't know how to start method adds with Array
    That doesn't worry me. What worries me to no end is that you apparently have no clue how to go find out. But perhaps I should stop worrying about people learning today or I'm going to pull out my hair. I'm going to say it one more time: get a good book on Java and read it; learn stuff -before- you need to be using it you know. There, I'm done.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. Replies: 7
    Last Post: 04-11-2013, 05:31 AM
  2. Replies: 4
    Last Post: 03-28-2013, 08:40 PM
  3. Array in Method Help
    By ETBunce in forum New To Java
    Replies: 2
    Last Post: 12-06-2012, 04:38 AM
  4. Need help with add method for array.
    By RozenKristal in forum New To Java
    Replies: 3
    Last Post: 10-15-2012, 04:38 AM
  5. help writing array method
    By katiebear128 in forum New To Java
    Replies: 3
    Last Post: 10-16-2011, 05:31 PM

Posting Permissions

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