Advertisement
Guest User

Untitled

a guest
Jul 15th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 1.07 KB | None | 0 0
  1. package ex05.task2
  2.  
  3. trait SedcSet [+A] {
  4.  
  5.   def + [B >: A] (item: B): SedcSet [B]
  6.  
  7.   def - [B >: A] (item: B): SedcSet [B]
  8.  
  9.   def size(): Int
  10.  
  11.   def contains [B >: A] (item: B): Boolean
  12.  
  13.   override def equals(obj: Any /*Any is correct as parameter to equals, do not modify*/): Boolean
  14.  
  15.   override def hashCode(): Int
  16.  
  17.   def print(printer: Printer [A]): Unit
  18.  
  19.   def foreach [B] (f: A => B): Unit
  20.  
  21. }
  22.  
  23. object SedcSet {
  24.   def apply[A](xs: A*): SedcSet [A]  = EmptySedcSet
  25. }
  26.  
  27.  
  28. object EmptySedcSet extends SedcSet[Nothing]  {
  29.  
  30.   override def + [A >: Nothing] (item: A): SedcSet [A] = ???
  31.  
  32.   override def -[B >: Nothing](item: B): SedcSet[B] = ???
  33.  
  34.   override def size(): Int = ???
  35.  
  36.   override def contains[B >: Nothing](item: B): Boolean = ???
  37.  
  38.   override def print(printer: Printer [Nothing]): Unit = ???
  39.  
  40.   override def foreach[B](f: Nothing => B): Unit = ()
  41.  
  42. }
  43.  
  44. trait Printer [-A] {
  45.  
  46.   def print(a: A):Unit
  47. }
  48.  
  49.  
  50. object Main {
  51.   // You may use any Java/ Scala standard collection inside this object
  52.   def main(args: Array[String]): Unit = {
  53.  
  54.   }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement