Please register

Report a typo

There are two types of users on our website. These classes are already represented in the scope:

trait User
object User:
  case class Unregistered(ipAdress: String) extends User
  case class Logged(login: String, id: Long) extends User

Write a function that will accept User and generate a greeting. If the user is not registered, you need to return "Hello! Please register". If the user is already logged in, you need to greet him with the login s"Hello, $login! Nice to see you again"

Sample Input 1:

User.Logged("Alex", 1)

Sample Output 1:

Hello, Alex! Nice to see you again
Write a program in Scala 3
def greetUser(user: User): String = ???
___

Create a free account to access the full topic