• Tidak ada hasil yang ditemukan

Computer Programming

N/A
N/A
Protected

Academic year: 2025

Membagikan "Computer Programming"

Copied!
3
0
0

Teks penuh

(1)

King Saud University

College of Computer and Information Sciences Department of Computer Science

CSC113 – Computer Programming II – Polymorphism lab – Spring 2016

Employee class:

o Attributes:

name: the name of the employee.

rank: rank in the company structure (1-15).

yearsOfExperience: number of years of experience for the employee.

o Methods:

Employee (name: String, rank: int, yearsOfExperience: int): constructor

getRank(): this method returns the rank of employee.

getYearsOfExperience (): returns the years of experience of the employee.

display(): this method display all the attributes of the employee.

calculateSalary(): this method calculates and return the Salary of the employee as the following:

o Employee: years of experience * 500 + rank * 1000

o Manager: years of experience * 500 + rank * 1500 + nbOfEmps * 10 o Consultant: hoursPerWeek * 1000 + rank *500

(2)

King Saud University

College of Computer and Information Sciences Department of Computer Science

CSC113 – Computer Programming II – Polymorphism lab – Spring 2016

Manager class:

o Attributes:

nbEmps: number of employees managed.

o Methods:

Manager (name: String, rank: int, yearsOfExperience: int, nbEmps: int): constructor

display(): this method display all the attributes of the manager.

getNbEmps(): this method returns the rank of employee.

Consultant class:

o Attributes:

hoursPerWeek: number of hours per week.

o Methods:

Consultant(name: String, rank: int, yearsOfExperience: int, hoursPerWeek: int):

constructor

display(): this method display all the attributes of the consultant.

Company class:

o Attributes:

name: the name of the company.

o Methods:

Company (name: String, size: int): constructor

addEmployee(Employee e): this method adds an employee to the company. An employee can be of type Employee, type Manager or type Consultant.

displayAll (): Display all employees and their attributes along with their salary.

countConsultant(): this method returns the number of all Consultants in the company.

(3)

King Saud University

College of Computer and Information Sciences Department of Computer Science

CSC113 – Computer Programming II – Polymorphism lab – Spring 2016

getHighSalary(double s): this method returns an array all employees with salary greater than s.

getManagers (int n): returns an array of all managers with nbEmps greater than n.

Write a class with a main method doing the following:

 Create the 3 objects as follows:

o emp: name = “Ahmed”, years of experience = 7, rank: 8

o manager: name = “Ali”, years of experience = 12, rank: 12, number of employees:

20

o consultant: name = “Hamad”, years of experience = 9, rank: 10, hoursPerWeek:

19

 Create the Company ”STC”.

 Add the previously crated objects in the company.

 Display all the employees.

 Display the number of consultants in the company.

 Display all employees with salary greater than SAR20,000.

 Display all Managers with number of employees greater than 10.

Referensi

Dokumen terkait

Production and hosting by Elsevier Journal of King Saud University – Computer and Information Sciences 201729, 427 King Saud University Journal of King Saud University – Computer and

ORIGINAL ARTICLE King Saud University Journal of King Saud University - Computer and Information Sciences www.ksu.edu.sa www.sciencedirect.com _of IOOi Siud lWYe""" -

ةيساردلا جهانملاو ططخلا ةنجل 221 Course Specifications Institution: KING KHALID UNIVERSITY , Abha Date: 24/02/2019 College/Department : COLLEGE OF COMPUTER SCIENCE / DEPARTMENT OF

Falke aDepartment of Computer Engineering, College of Computer and Information Sciences, King Saud University, Riyadh, Saudi Arabia bCenter of Smart Robotics Research, King Saud

1 Ghadah Ahmed Al-Jarallah Lecturer, Computer Science Education: MSc Computer Science & Information Technology, King Saud University, Riyadh, 2018 BSc Computer Science & Information

Member, Committee of recruitments and promotions Department of Biochemistry, College of Science, Sciences & Medical Studies Department for Women Students, King Saud University,

King Saud University College Of Computer & Information Sciences Department Of Computer Sciences Tutorial 1 Fall 15 Computer Networks CSC 329 1.. Define the concept of layer and

Member, Research Cooperation Committee 2020-till date Department of Biochemistry, College of Science, Sciences & Medical Studies Department for Women Students, King Saud University,