Skip to content
Snippets Groups Projects
Commit f75eaf04 authored by Nicolas Alexander Stucki's avatar Nicolas Alexander Stucki
Browse files

Use traits

parent e429b9a2
No related branches found
No related tags found
No related merge requests found
......@@ -16,7 +16,7 @@ Note that the above defines a total order.
Here is the structure we will be using for implementing these trees:
```scala
abstract class Tree[T] { ... }
trait Tree[T] { ... }
case class EmptyTree[T](leq: (T, T) => Boolean) extends Tree[T] { ... }
case class Node[T](left: Tree[T], elem: T, right: Tree[T],
leq: (T, T) => Boolean) extends Tree[T] { ... }
......@@ -39,7 +39,7 @@ Given only `leq` for comparison, how can you test for equality? How about strict
Define the size method on `Tree[T]`, which returns its size, i.e. the number of Nodes in the tree.
```scala
abstract class Tree[T] {
trait Tree[T] {
def size: Int
...
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment