Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8139491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:50:28+00:00 2026-06-06T11:50:28+00:00

I am making an EmployeeStore that will store names, dob, id, email address etc…

  • 0

I am making an EmployeeStore that will store names, dob, id, email address etc… and i need to write an edit method. I have googled and i cannot find how to do this can anyone help? Here is my code:

//Imports.
import java.util.Scanner;
//********************************************************************  
public class MainApp
{
    private static Scanner keyboard = new Scanner(System.in);

    public static void main(String[] args)
    {
        new MainApp().start();

    }
    public void start()
    {
        EmployeeStore Store = new EmployeeStore();
        Store.add(new Employee ("James O' Carroll", 18,"hotmail.com"));

        Store.add(new Employee ("Andy Carroll", 1171,"yahoo.com"));

        Store.add(new Employee ("Luis Suarez", 7,"gmail.com"));
//Test Code with the new Hashmap.       
        /*Store.print();
        Store.clear();
        Store.print();

        Store.add(new Employee ("James O' Carroll", 18,"hotmail.com"));

        Store.add(new Employee ("Andy Carroll", 1171,"yahoo.com"));

        Store.add(new Employee ("Luis Suarez", 7,"gmail.com"));

        Store.print();
        Store.remove("Andy Carroll");
        Store.print();*/
//********************************************************************  
        //Switch Statement for use of a menu.
         int choice;
            do {
                choice = getMenuChoice("1.\tLibrarian\n2.\tPublic User\n3.\tExit\n\n", 3, "Please enter choice:", "Error [1,3] only");
                switch (choice) {
                    case 1:
                        System.out.println("Librarian Functionality...\n");
                        break;
                    case 2:
                        System.out.println("Public User functionality...\n");

                        break;
                    case 3:
                        System.out.println("Program Finished");

                }
            }
            while (choice != 3);
}
//********************************************************************  
      public static int getMenuChoice(String menuString, int limit, String prompt, String errorMessage) 
      {
            System.out.println(menuString);
            int choice = inputAndValidateInt(1, limit, prompt, errorMessage);
            return choice;
       }
//********************************************************************  



        public static int inputAndValidateInt(int min, int max, String prompt, String errorMessage) {
            int number;
            boolean valid;
            do {
                System.out.print(prompt);
                number = keyboard.nextInt();
                valid = number <= max && number >= min;
                if (!valid) {
                    System.out.println(errorMessage);
                }
            } while (!valid);
            return number;
        }
//********************************************************************  
}


//Imports:

//********************************************************************
//Employee Class.
public class Employee
{
//Variables.
    private String employeeName;
    private int employeeId;
    private String employeeEmail;
//********************************************************************  
//Constructor.
    public Employee(String employeeName, int employeeId, String employeeEmail) 
    {
        this.employeeName = employeeName;
        this.employeeId = employeeId;
        this.employeeEmail = employeeEmail;
    }
//********************************************************************
//Getters.
    public String getEmployeeEmail() {
        return employeeEmail;
    }
    public void setEmployeeEmail(String employeeEmail) {
        this.employeeEmail = employeeEmail;
    }
    public String getEmployeeName() {
        return employeeName;
    }
    public int getEmployeeId() {
        return employeeId;
    }
//********************************************************************
//toString method.
    public String toString() {
        return "Employee [employeeName=" + employeeName + ", employeeId="
                + employeeId + ", employeeEmail=" + employeeEmail + "]";
    }
//********************************************************************





}
//Imports.
import java.util.HashMap;
//********************************************************************
import java.util.Map;

public class EmployeeStore 
{
    HashMap<String, Employee> map;

//Constructor.  
    public EmployeeStore()
    {
        map = new HashMap<String,Employee>();
    }
//********************************************************************
//Hashmap Methods.
//Add to the Hashmap : Employee.
    public void add(Employee obj)
    {

        map.put(obj.getEmployeeName(), obj);
    }
//********************************************************************
//Remove from the Hashmap : Employee.
    public void remove(String key)
    {
      //Remove the Employee by name.
        map.remove(key);
    }
//********************************************************************
//Clear the Hashmap : Employee.
    public void clear()
    {
        map.clear();
    }
    //********************************************************************
//Print the Hashmap : Employee. 
    public void print()
    {
        System.out.println("\n********Employee's in the Company.********");
        for (Employee employee : map.values())
        {
            System.out.println("Employee Name:\t" + employee.getEmployeeName());
            System.out.println("Employee Id:\t" + employee.getEmployeeId());
            System.out.println("E-mail:\t"+ employee.getEmployeeEmail());
        }

    }


//********************************************************************  
//********************************************************************


}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T11:50:29+00:00Added an answer on June 6, 2026 at 11:50 am

    You’ll need to fetch the Employee object from the HashMap, then modify the object. For example, to change the email:

    //in class EmployeeStore
    String email = somehowGetNewEmail();
    Employee toEdit = map.get(somehowGetName());
    toEdit.setEmail(email)
    

    Alternately:

    //in EmployeeStore
    public Employee get(String name){
        return map.get(name);
    }
    
    //in any class with reference to an EmployeeStore "store"
    store.get(name).editSomething(something);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Making a form that will accept a bunch of textual data and an image
Making game of life I need to a have a grid that is 30x20
I'm making an employee store. The delete function in the employeeStore does not work.
Making a small WCF test program which is based on a Store that has
Making an adobe flex ui in which data that is calculated must use proprietary
Making UML sequence diagram in VS 2010RC I've observed that there is no activation
Making websites that appear correctly in IE is a big problem. Is there any
Making a flash page that can cycle through these three images on mouseclick. For
Making an Flex App. Just wondering if anyone has created something that fits automatically
Im making a simple rock paper scissors game and I need to use the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.