View Single Post
Old 04-29-2010   #1
7anzala
Registered Member
 
7anzala's Avatar
 
Last Online: 05-15-2012
Join Date: Sep 2006
Posts: 530
Thanks: 9
Thanked 41 Times in 34 Posts
Groans: 0
Groaned at 1 Time in 1 Post
Default Java Please Help ASAP

hey all I have to submit this before midnight and i know nothing about any one can help??????

(a)
The class UFOSurvey needs a single private instance variable called alienSightings. Write the declaration for this variable considering that:
o
It should be declared to be of a suitable interface type to hold a map whose keys are integers, and whose values are a set of strings.
o
More colors may need to be added to any area at any time. An area code is only included when there is color data recorded for that area. The data should be stored in such a way that the area codes are kept in ascending numerical order when new area codes are added.
o
The colors for each area code need not be kept in any specific order. For any given area code, a given color should never be recorded more than once.

hala2 I solved That :

private Map<Integer,Set<String>> alienSightings;
{
}



(b)
Write a zero-argument constructor that creates an empty instance of a suitable class that implements a map and assigns it to alienSightings.

and i solved that kamen:

public UFOSurvey()
{
super();
alienSightings=new TreeMap<Integer,Set<String>>();

}

(c)
Write an instance method for the UFOSurvey class called addSighting(). The method should take two arguments, one for an area code, and one for a colour. If this is a new area code the method should add an entry to the map for that code with the given colour, otherwise the method should simply add a colour to the existing collection of colours for that area, unless that colour is already in the collection, in which case there should be no change. The message answer should be true if the map has changed, otherwise false.
(d)
The UFOSurvey class needs a second instance method called findAreasForColour() which takes a string argument and returns a set of all areas with a sighting of that colour. This method should work irrespective of how many entries might subsequently be added to alienSightings.

please help me.....
__________________
ALEXANDER Al-Kabeer
Gonna rule you all...
7anzala is offline