Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 4th, 2008, 10:07 AM
tehwabbit tehwabbit is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2007
Posts: 22 tehwabbit User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 45 m 14 sec
Reputation Power: 0
Exclamation DVD Rental Project || ARRAY Search needs tweaking

Mass edit:

Ive fixed it somehow and at the second i have the following code:

java Code:
Original - java Code
  1.  
  2.  
  3. public class Database
  4. {
  5.     private ArrayList<Item> items;
  6.     private ArrayList<Family> customer;
  7.     private ArrayList<Rental> rental;
  8.     private Item Result;
  9.  
  10. ... code snipped...
  11.  
  12.     public void searchTitle(int searchString)
  13.    {
  14.      int index = 0;
  15.      boolean found = false;
  16.      System.out.println(searchString + " Debug Initialized:");
  17.      while(index < items.size() && found == false) {
  18.       System.out.println(searchString + "while loop @" + index)
  19.         if(items.get(index).barcode == searchString) {
  20.             found = true;
  21.             Result = items.get(index);
  22.             System.out.println(searchString + " was found and 'Result' has been changed:");
  23.          
  24.         }
  25.         else {
  26.             index++;
  27.         }
  28.    
  29.     }
  30. }


It works and grabs the info @ entry: barcode
and then palces this in Result

but i cant use Result[0] Result[1] etc to get the resutls

Anyone~
?

Reply With Quote
  #2  
Old May 5th, 2008, 03:29 PM
sberg43 sberg43 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Norway
Posts: 50 sberg43 User rank is Sergeant (500 - 2000 Reputation Level)sberg43 User rank is Sergeant (500 - 2000 Reputation Level)sberg43 User rank is Sergeant (500 - 2000 Reputation Level)sberg43 User rank is Sergeant (500 - 2000 Reputation Level)sberg43 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 12 h 24 m 50 sec
Reputation Power: 16
Quote:
Originally Posted by tehwabbit
but i cant use Result[0] Result[1] etc to get the resutls

Result is an instance of the Item class and does not appear to extend or implement a collection/list. So natural you can't use it as a list.

Maybe you meant to write items[0], itemes[1]? Well, you cant do that either. You can only (as far as I know) use the brackets on instances of the Array class, not on instances of the ArrayList class.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > DVD Rental Project


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway