🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #730

list class (long)

#730
From: Scott
Date: Tue, 14 Dec 2004 20:21
47 lines
3558 bytes
Hello all, been lurking in this group for awhile. Found a lot of tidbits 
that have been helpful. Now I'm attempting to teach myself java an dhave a 
decent book to help but I'm currently having some trouble with array/lists. 
I'll write out an example of the type of problem I'm having and hopefully 
some of you can help, or at least direct me to the apprpriate place for some 
help.

I want to createa class called List that will remember a list of strings. 
It'll (hopefully) have methods that will do the following. I apologise for 
the length of this post, just trying to do these things. I figured that a 
list/dictionary would be a simple example of this.  I'd like to be able to 
sory in alphabetical  and something I can use this list to maintain an email 
list. Any help anyone can provide would be great. Thanks in advance

List()-creates a list capable of holding 4 strings
List(int n) - creates a list capable of hold n strings
void add(String s) - adds the string s to the list, increasing the list size 
if necessary
boolean contains(String s)-  returns true if the String s is in the list
void remove(String s) - removes the String s if it is in the list
String toString() - returns a printable representation of th elist
int locate(String s) - return the integer index of where the string s is in 
the list, if it doesn't exist
I'd like a -1.
String get(int n) - returns the string at location n, null if it's out of 
range.

Once I have that...I'd like to create another class called Dictionary that 
acts like a dictionary. for example, I know one word and using a dictionary 
I get a bunch of other words, the definition.
The methods I'd be interested in implementing here are pretty much teh same 
as above

Dictionary() - create a dictionary that can hold 4 entries
Dictionary(int n) - create a dictionary that can hold n entries
void add(String key, String value) - add the key/value pair to the 
dictionary;increase size as necessary.
void remove(String key) - remove the key/value pair
String lookup(String key) - return the value assoc.to key. return null if 
not there
String []lookupPart(String keyPart) - returns a list of values whose keys 
have valuePart as a subString
String[]reverseLookup(String valuePart) - returns a list of values whose 
keys have valuePart as a subString
boolean contains(String key)returns true/false if the key is in the 
dictionary
String toString()return printable representation of the dictionary
Technical Details
Message-ID: <4XHvd.12318$Ae.1427@newsread1.dllstx09.us.to.verio.net>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newsread.com!newsprint.newsread.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.dllstx09.us.to.verio.net!verio!newsread1.dllstx09.us.to.verio.net.POSTED!53ab2750!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: f74b3,3f0cbc3440ab15d9,start
X-Google-Attributes: gidf74b3,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newsread.com!newsprint.newsread.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.dllstx09.us.to.verio.net!verio!newsread1.dllstx09.us.to.verio.net.POSTED!53ab2750!not-for-mail
From: "Scott" <swurm@suffolk.lib.ny.us>
Newsgroups: borland.public.jbuilder.java.language
Subject: list class (long)
Lines: 50
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
Message-ID: <4XHvd.12318$Ae.1427@newsread1.dllstx09.us.to.verio.net>
Date: Tue, 14 Dec 2004 15:21:20 -0500
NNTP-Posting-Host: 209.139.23.142
X-Complaints-To: abuse@verio.net
X-Trace: newsread1.dllstx09.us.to.verio.net 1103055680 209.139.23.142 (Tue, 14 Dec 2004 20:21:20 GMT)
NNTP-Posting-Date: Tue, 14 Dec 2004 20:21:20 GMT
Organization: NTT/VERIO