An object instead of a class

Report a typo

Implement the Banana, Orange, Apple objects that inherit from the Fruit class.

Sample Input 1:

Sample Output 1:

apple
orange
banana
Write a program in Scala 3
class Fruit(val name: String, val color: String)

class Apple() extends Fruit("apple", "greed")
class Orange() extends Fruit("orange", "orange")
class Banana() extends Fruit("banana", "yellow")
___

Create a free account to access the full topic