The class in question is the one below:
public Customer(String aName, String anAddress, int anArea)
{
this.fullName = aName;
this.address = anAddress;
this.area = anArea;
}
I created the map like so (the customers variable is initialised separately, creating a hashmap):
public void addCustomer(String regNo, String name, String address, int area)
{
customers.put(regNo, new Customer(name, address, area));
}
What I want the program to do is to iterate through the map, checking for customers that have a specific area number.
The method header looks like this:
public Customer findCustomersInArea(int area)
{
}
I created a separate method that iterates through the map using a for each loop, which prints all the details associated with a Customer object and I have tried to emulate this method but to no avail. It looks like this:
public void printCustomers()
{
Set<String> customerKeys = customers.keySet();
for (String eachCustomer: customerKeys)
{
System.out.println (customers.get(eachCustomer));
}
}
I hope I have been clear, please let me know if I need to give more details.