1. Trang chủ
  2. » Luận Văn - Báo Cáo

Lập trình hướng đối tượng: Workshop 10

2 16 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 2
Dung lượng 66,57 KB

Nội dung

Upon instantiation, a Manager object may receive an integer identifying the number of employees for which the manager is responsible, an integer identifying the manager’s employ[r]

(1)

Workshop 10 Task 1: Employee

Design and code a class named Employee that holds information for an employee Upon instantiation, an Employee object may receive an integer identifying the employee and a double

holding the employee’s salary If the object does not receive any data, or receives invalid data, the object adopts a safe empty state

Your Employee class includes the following member functions:

void display() const

o Displays the employee number followed by the salary in (NNNN) - $$$$$$$$$$ format, where NNNN denotes the employee’s number and $$$$$$$$$$ denotes the employee’s salary

o Displays the employee number in a field of and the salary in a field of 10 to decimal places

bool valid() const

o Returns true if the object holds valid data, false otherwise

Your Employee class is supported by an extraction operator For the purpose of this workshop, you may assume that the user will input the data correctly

Task 2: Manager

Derive a class named Manager from Employee that holds information for a manager Upon instantiation, a Manager object may receive an integer identifying the number of employees for which the manager is responsible, an integer identifying the manager’s employee number and a double holding the manager’s salary If the object does not receive any data or receives invalid data, the object adopts a safe empty state

Your Manager class includes the following member functions:

void display() const

o Displays the employee information for the object followed by the number of employees for which the manager is responsible in (NNNN) - $$$$$$$$$$ - (RRR) format, where NNNN - $$$$$$$$$$ denotes employee information and RRR denotes the number of employees

bool valid() const

(2)

o Returns true if the object holds valid data, false otherwise

Your Manager class is supported by an extraction operator For the purpose of this workshop, you may assume that the user will input the data correctly

Note:

The main program that uses your class is The output from your program looks something like:

Ngày đăng: 09/03/2021, 05:40

TỪ KHÓA LIÊN QUAN

w