codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  HashMap question  maig at 22:07 on Friday, May 12, 2006
 

I'm trying to complete another assignment for my online course, and I'm having trouble getting it. I've learned about ArrayLists and HashMap in separate lessons but now I'm supposed to create a HashMap with an ArrayList as the "value". I am totally stuck. The program is supposed to be a simple MailServer and MailClient. I've done the MailClient and the MailItem classes but I'm having a lot of trouble with MailServer. I need to do a "post" method that take the info from the sendMessage info from MailClient and puts it into a HashMap, but the value should be an ArrayList of all the messages. Confusing!

Here is what I have so far... not sure if I need to post the MailClient code or not for help...

/**
* Add the given message to the message list.
* @param item The mail item to be stored on
the server.
*/
public void post(String name, MailItem item)
{
ArrayList list = new ArrayList();
messages.put(name, item);
}


the "name" parameter should be the user name which is set when you create a MailClient object.

Now I know this isn't correct, any help appreciated.

maig


  Re: HashMap question  maig at 07:30 on Saturday, May 13, 2006
 

I have found a way to do this now, but my MailClient is complaining. Is there a way to fix this method from MailClient:

public void sendMessage(String to, String subject, String message)
{
MailItem mess = new MailItem(to, user, subject, message);

server.post(mess);
}

So that it can use my new post method in MailServer?

public void post(String name, MailItem item)
{
if(messages.containsKey(name) == true) // if the key already exists
{
ArrayList list = (ArrayList) messages.get(item); // add the item to the arraylist
}
else
{
ArrayList list = new ArrayList(); // if the key doesn't exist, create a new ArrayList
messages.put(name, list); // add the mailItem to the ArrayList
}
}

The compiler is hanging on the server.post(mess) line as it is expecting (String, MailItem)


  Re: HashMap question  miteshbhimjiyaani at 09:47 on Tuesday, May 16, 2006
 

hi
can u send me signature or syntax of server.post() method.











CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Digital.Canal.Software.V2013
•  Altair_HyperWorks_12.0.1_Win64
•  Global.mapper.V15.0
•  ESI.PAM-RTM.V2010.0
•  KISSsoft.03.2013E.SP5
•  Technical.Toolboxes.Pipeline.Toolbox.2013.Enterprise.v15.0.0
•  Simprotek.Simprosys.V3.0
•  Ricardo.SABR.V6.0p1
•  PSIM.V9.2


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2013