hello Friends:;
I have question and I wont your help.. I do it,but I'm stuk in printing :icon_cry:.. This the code,
I hope you can help ,, Thanks
Write a class TelephoneDirectory. It has a telephoneList attribute as a HashMap. The TelephoneDirectory has the following methods:
a.addTelephoneEntry ( TelephoneNumber number, Person person )
b.removeTelephoneEntry ( TelephoneNumber number )
c.printTelephoneDirectory()
CODE:icon_wink: words in red I'm not sure this or other statment correct
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;
public class TelephoneDirectory {
HashMap telephoneList;
public TelephoneDirectory (){
telephoneList = new HashMap ();
}
public void addTelephoneEntry(TelephoneNumber Number , Person person ){
// Add the person with its key to the telephoneList
/*
Set myKeys = telephoneList.keySet();
Iterator i= myKeys.iterator();
while(i.hasNext())
{
Number = (TelephoneNumber)i.next();
person = (Person) telephoneList.get(Number);
*/ telephoneList.put(Number,person);
}
public void removeTelephoneEntry(TelephoneNumber Number){
telephoneList.remove(Number);
}
public void PrintTdirectory(){
Set myKeys = telephoneList.keySet();
Iterator i= myKeys.iterator();
while(i.hasNext()){
TelephoneNumber Number = i.next();
System.out.print( Number+ " ");