Question: Create a HashTable for this PhoneBook class in Java: Info: PhoneBook, which represents the phone book. The class should contain a hash table as a
Create a HashTable for this PhoneBook class in Java:
Info:
PhoneBook, which represents the phone book. The class should contain a hash table as a datafield. This table contains the people in the book. The phone book should contain the add,delete, find, change, quit, save and restore methods.
HashTable, which is the ADT HashTable. This is the class which contains the PhoneBooks collection of data (all of the People objects in the PhoneBook), as well as the operations which can be performed on that collection of data.
My PhoneBook class:
public class People {
String Name; Integer Phone; People(int Phone,String Name ){ this.Phone=Phone; this.Name=Name; } public String getName() { return Name; } public void setName(String name) { Name = name; } public int getPhone() { return Phone; } public void setPhone(int phone) { Phone = phone; } }
Then create the Phone book class, which is going to use the above People class as value and phone number as the key in the HashMap entries.
import java.security.KeyStore.Entry; import java.util.HashMap;
public class PhoneBook { HashMap
}
Basic HashTable format example that I would like to use:
public class HashTableDemo { public static void main(String args[]) { // Create a hash map Hashtable b = new Hashtable(); names; String gg; name.put("Name", new Double(0004.34)); name.put("Name", new Double(100.002)); name.put("Name", new Double(1008.00)) // Show all anme in hash table. names = balance.keys(); while(names.hasMoreElements()) { gg = (String) names.nextElement(); System.out.println(gg + ": " + name.get(gg)); } System.out.println(); } } Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
