-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathemployee.dart
More file actions
43 lines (35 loc) · 1.46 KB
/
employee.dart
File metadata and controls
43 lines (35 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
void main(){
print(" **** Module 5 – Assignment **** ");
print(" ");
// Create a Manager object with name, department, and salary
Manager john = Manager('John', 'Manager', 90000);
john.infodisplay();
print(" ");
// Create a Developer object with name, programming language, and salary
Developer alex = Developer('Alex', 'Dart', 80000);
alex.infodisplay();
}
// --------------------- Employee Base Class ---------------------
class Employee{
String name; // Employee's name
double salary; // Employee's salary
Employee(this.name, this.salary); // Constructor for Employee class
}
// --------------------- Manager Class ---------------------
class Manager extends Employee{
String department; // Manager-specific property
Manager(super.name, this.department, super.salary); // Constructor: calls Employee constructor (name, salary) and initializes department
// Method to display Manager's details
void infodisplay(){
print("Name: $name \nDepartment: $department \nSalary: $salary ");
}
}
// --------------------- Developer Class ---------------------
class Developer extends Employee{
String programmingLanguage; // Developer-specific property
Developer(super.name, this.programmingLanguage, super.salary); // Constructor: calls Employee constructor (name, salary) and initializes programming Language
// Method to display Developer's details
void infodisplay(){
print("Name: $name \nLanguage: $programmingLanguage \nSalary: $salary ");
}
}