The problem in your code is type parameter shadowing.
You have:
class ThreeStacks[A, B, C](val stackSize:Int = 1000) {
def push1[A](value: A): Unit = stack1.push(value)
...
}
It should be:
class ThreeStacks[A, B, C](val stackSize:Int = 1000) {
def push1(value: A): Unit = stack1.push(value)
...
}
The way you have done it, type parameter A
of class ThreeStacks
and type parameter A
of method push1
are completely different ones and thus, are incompatible with each other.
The same applies to B
and C
.