Total members 10261 | Gratitudes |It is currently Wed May 23, 2012 9:23 am Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 1 post ] 
Author Question
 Question subject: New in java
PostPosted: Tue Nov 30, 2010 10:06 am 
Offline
Newbie
User avatar

Joined: Tue Nov 30, 2010 9:46 am
Posts: 1
Has thanked: 0 time
Have thanks: 0 time

I had some problem in Map in Java
I don't understand it very well

I try to solve some activity but I don't sure is correct
if any body can help me to check it to me

Thanks









The following table shows model area code and names of five star Houses in that area.

Area Code House names
141 “adison Sas”
142 “FourSeasons”
145 “life Regency”
147 “Sartoon”

This table is implemented by instances of a class called HouseCatalogue.

(a) Declare a private instance variable (Attribute) called HouseMap which should hold an unsorted map with integer keys and string values.

Private Map< Integer, String> HouseMap = new HashMap<Integer, String>();

(b) Write a zero-argument constructor of HouseCatalogue that initializes HouseMap to an empty map.
HouseMap.isEmpty();
(c) Write an instance method called addHouse() for the HouseCatalogue class that takes no arguments, and returns no value. This method should simply enter the four entries shown above into the HouseMap.
Public void addHouse()
{
HouseMap.put(141," Radison Sas") ;
HouseMap.put(142," ForSeason ") ;
HouseMap.put(145," Hayat Regency ");
HouseMap.put(147," Concord al-Salam ") ;
}



** an instance method called printHouse() for the HouseCatalogue class that takes an integer as argument and return a string value. This method should print the value (House name) of the area code that is equal to integer argument and return it. Otherwise it will return null.
Public string printHouse( int area)
{
for(Integer eachcode : HouseMap.keySet())
{ if ( HouseMap.keySet()== area)

{
System.out.println("House name is"+ HouseMap.get(eachcode));
}
}
}




==============


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 1 post ] 
Quick reply


  

 Similar topics
 video chat application in java
 navigating to database using java
 java mobile apps
 need help in java
 Read your gmail using Java code
 Java Programing to communicating port parallel
 Java Chat
 Steganography in java
 java code for listing folder contents from remote folder
 java

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: Google Adsense [Bot] and 4 guests



Jump to:  
Previous Question | Next Question 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team