0% found this document useful (0 votes)
16 views1 page

(2 Marks) Employee: Public Class Employeelist Extends Arraylist (// ..)

The document describes a Employee class with properties like id, name, salary and methods like getId(), getName(), setName(), getSalary(), setSalary(), getNameById(), getEmployeeWithMaxSalary(), and toString(). It also describes an EmployeeList class that extends ArrayList and includes methods getEmployeeSalaryById() and getEmployeeWithMaxSalary(). The EmployeeList class is used to store and retrieve Employee objects.

Uploaded by

quanghoaluu1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views1 page

(2 Marks) Employee: Public Class Employeelist Extends Arraylist (// ..)

The document describes a Employee class with properties like id, name, salary and methods like getId(), getName(), setName(), getSalary(), setSalary(), getNameById(), getEmployeeWithMaxSalary(), and toString(). It also describes an EmployeeList class that extends ArrayList and includes methods getEmployeeSalaryById() and getEmployeeWithMaxSalary(). The EmployeeList class is used to store and retrieve Employee objects.

Uploaded by

quanghoaluu1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1

(2 marks)

Write a class named Employee with the following information:


Employee Where:
 Employee() - default constructor
- id: int
- name:String  Employee(id: int, salary: double) – constructor:
- salary: double set values to the id, and the salary
+ Employee ()  getId():int – return the id
+ Employee(id: int, salary: double)  getName():String - return the name in upper
+ getId():int case
+ getName():String
+ setName(value: String): void  setName(value: String): void - set the value to
+ getSalary():double the name
+ setSalary(value: double): void  getSalary():double - return the salary
+ toString(): String  setSalary(salary: double): void – set the value to
+getNameById(id: int):double the salary
+getEmployeeWithMaxSalary (): Employee
 getNameById(id: int):double - return the name
in uppercase of the employee by id.
 getEmployeeWithMaxSalary (): Employee -
return the employee with the highest salary
 toString(): String – return the string of format:
id, name, and salary. The salary is formatted
with two decimal places and name in uppercase

Write a class EmployeeList which extends from ArrayList (ArrayList is a collection) with the following
information :
EmployeeList Hints: to declare the EmployeeList class, you can use
the following statement:
public class EmployeeList extends ArrayList<Employee>
+getEmployeeSalaryById (int id): double
{
+getEmployeeWithMaxSalary (): Employee //…..
}

The program output might look something like this (using the EmployeeList class):
Case #1: Case #2:
Enter the number of employees:2 Enter the number of employees:2
#Employee 01 #Employee 01
Enter id:1 Enter id:1
Enter name:Tom Enter name:Tom
Enter salary:3000 Enter salary:3000
#Employee 02 #Employee 02
Enter id:2 Enter id:2
Enter name:David Enter name:David
Enter salary:3000.111 Enter salary:4039.111
1.Test getNameById() 1.Test getNameById()
2.Test getEmployeeWithMaxSalary() 2.Test getEmployeeWithMaxSalary()
Enter TC(1/2):1 Enter TC(1/2):2
Enter id:1 OUTPUT:
OUTPUT: 2,DAVID,4039.11
TOM

You might also like