0% found this document useful (0 votes)
27 views

Question File

The document describes creating an Employee class with private attributes for employee ID, name, and city. An EmployeeDemo class is created with a main method and two public methods: searchEmployee searches an ArrayList of Employees by ID and returns true if found, false if not; getEmployees counts Employees in an ArrayList belonging to a given city, returning the count or 0 if none are found. The classes are built within the "com" package following the outlined class diagram.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

Question File

The document describes creating an Employee class with private attributes for employee ID, name, and city. An EmployeeDemo class is created with a main method and two public methods: searchEmployee searches an ArrayList of Employees by ID and returns true if found, false if not; getEmployees counts Employees in an ArrayList belonging to a given city, returning the count or 0 if none are found. The classes are built within the "com" package following the outlined class diagram.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Create class Employee with below attributes:

empId
empName
city

Create class EmployeeDemo with main method. This Class EmployeeDemo will have
following two methods:

1. searchEmployee
This method will take an ArrayList of Employee Class Objects as its first parameter
and a single Employee Object as its second parameter. The method will search if the
Employee Object is present in the ArrayList of Employees or not based on empId. If it is
present, the method will return true else the method will return false.

2. getEmployees
This method will an ArrayList of Employee Class Objects as its first parameter and a
name of City of String datatype as its second parameter. The method will count the
number of employees in the ArrayList belonging to this city. The method returns 0, if
no employee in the ArrayList belong to the given city else returns the count of the
number of employees in the ArrayList belonging to this city.

Follow class outline diagram as given below. Ensure class attributes are private and other
methods are public. Use package “com” to build your solution.

You might also like