Skip to content

Commit 4c0e8ac

Browse files
authored
Update EmployeeScript.scala
MEthod overriding
1 parent 8d26414 commit 4c0e8ac

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

4.Classes-Objects/EmployeeScript.scala

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ val dept = new Department("Computer Science")
3131
val mgr = new Manager("Alan", "Turing", "Mathematician", dept)
3232
println("Department:" + mgr.department.name)
3333

34+
println("Full Name:" + mgr.fullName)
35+
36+
val cpyMgr = mgr.copy(title="Encryption")
37+
println("Copied Manager: " + cpyMgr.fullName + "-" + cpyMgr.title)
38+
3439
/**
3540
*Sample output
3641
*
@@ -103,4 +108,20 @@ Title cannot contain Senior or Junior!!
103108
Continuing with program
104109
Department:Computer Science
105110
111+
--------------After adding changes for method overriding
112+
E:\Courses\scala\IntellijIDEA\src>scala -nc EmployeeScript.scala
113+
Multiline constructor block!!
114+
FirstName:Gabbar
115+
LastName:Singh
116+
Modified LastName :Babbar
117+
title:Programmer
118+
requirement failed: Last Name cannot be empty!!
119+
Continuing with program
120+
Title cannot contain Senior or Junior!!
121+
Continuing with program
122+
Department:Computer Science
123+
Full Name:Alan Turing, Computer Science, Manager
124+
Copied Manager: Alan Turing, Toys, Manager-Encryption
125+
126+
106127
*/

0 commit comments

Comments
 (0)