-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathl10.scala
More file actions
22 lines (19 loc) · 889 Bytes
/
Copy pathl10.scala
File metadata and controls
22 lines (19 loc) · 889 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
abstract class Notification
case class Email(sender: String, title: String, body: String) extends Notification
case class SMS(caller: String, message: String) extends Notification
object a{
def main(args:Array[String]){
def showNotification(notification: Notification): String = {
notification match {
case Email(email, title, _) =>
s"You got an email from $email with title: $title"
case SMS(number, message) =>
s"You got an SMS from $number! Message: $message"
}
}
val sSMS=SMS("12345","are u der?")
val sEmail=Email("xyz@email.com","BD","BD class")
println(showNotification(sSMS))
println(showNotification(sEmail))
}
}