Results 1 to 2 of 2

Thread: Array

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2007
    Posts
    50

    Array

    Code:
    public boolean takeOut(CD aCD, Person aPerson)
    	{
    		int out;
    		if((out = discsArray.indexOf(aCD)) != 0)
    		{
    			CD cd = (CD)discsArray.get(out);
    
    			if(cd.person == null)
    			{
    				cd.person = aPerson;
    				discsArray.set(out, cd);
    				return true;
    			}
    		}
    i use this code to remove an item from the array, how would i implement this on the gui so that when i enter a persons name and the item they want to take out in textfields and press the button it should check the array to see if the item is there then remove the item from the list?

    Code:
    if(e.getSource() == takeOut)
    		{
    			if(takingOutCD.getText().equals(""))
    			{
    				display.setText("Please Enter Person Taking Out CD");
    			} //End if
    
    			else if(cdBeingTakenOut.getText().equals(""))
    			{
    				display.setText("Please Enter Title Of CD Being Taken Out");
    			} //End else if
    
    			else
    			{
    				display.setText("CD Taken Out By: " + p1);
    			}
    		}

  2. #2
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Array

    Have you considered using other data structures, e.g. ones that provide key based retrieval and deletion?

Posting Permissions

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



Click Here to Expand Forum to Full Width