10
100
Question 3:
(3 marks) Write a class Employee(in the default package) with the following information:
Employee
Where:
-id:int
- firstname: String
Employee ():default Constructor.
- lastname: String
Employee (id:int, firstName: String, lastName: String,salary:int):Constructor with id, firstName, lastName and salary.
- salary:int +Employee ()
getID():int-return employee id.
+Employee (id:int, firstName: String, lastName: String,salary:int)
getfirstName():String-return employee first name.
getlastName():String-return employee last name.
+getID():int
getSalary():int-return employee salary.
+getFirstName():String
setID(id:int):void-set employee id.
+getlastName():String
+getSalary(): int
setFirstName(firstName:String):void-set employee first name.
setLastName(lastName: String):void-set employee
+setID(id:String):void
last name.
+setFirstName(firstName:String):void
+setlastName(lastName:String):void
setSalary(salary:int):void set employee salary.getName() String-return the employee's name.
+setSalary(salary:int):void
getAnnualSalary():int-return the employee
salary 12.
+getName():String
raiseSalary(percent:int):int-return the employee raise salary percent.
+getAnnualSalary(): int
+raiseSalary(percent:int):int
toString():String: overriding the toString method and return a string following format "Employee[id="",name="",salary=""]".
+HoString(): String
Hint: a name includes a last name, "" and a first name.
4 of 4
Paper No: 1
Zoom
+ 80%
Close