---
# System prepended metadata

title: 12. Type parameters and opaque types in classes in Scala homework

---

# 12. Type parameters and opaque types in classes in Scala homework

## Задания
### Preface
*All tests should pass.*
I have additional test for the functionality. My tests also *should pass*. Feel free to add more test cases.

### How to pass
Create a new branch `homework-12`. You *should not* commit your solution to your `*master*` branch, only to `homework-12` branch.
You can do as many commits as you want to `homework-12`.
Please provide any commit wiht meaningful commit message following the format
```
HOMEWORK-12 - <brief explanation>

<detailed explanation if neede>
```

Yes, `HOMEWORK-12` is in upper case.
Yes, `HOMEWORK-12` then ` ` (**space**) then `-` (**dash**) then ` ` (**space**) then  brief explanation.

After the implementation (with tests) is done create *merge request* (aka code review aka pr) and add me as a reviewer... and the battle begins! 

### Rational numbers
#### Review the following code
* https://github.com/KarazinScalaUsersGroup/scala-course-2020/blob/master/src/test/scala/karazin/scala/users/group/classes/homework/arbitraries.scala
* https://github.com/KarazinScalaUsersGroup/scala-course-2020/blob/master/src/test/scala/karazin/scala/users/group/classes/homework/HomeworkSpecification.scala

#### Code templates
The implementation should be done here:
* https://github.com/KarazinScalaUsersGroup/scala-course-2020/blob/master/src/test/scala/karazin/scala/users/group/classes/homework/arbitraries.scala
* https://github.com/KarazinScalaUsersGroup/scala-course-2020/blob/master/src/test/scala/karazin/scala/users/group/classes/homework/HomeworkSpecification.scala

Your goal is to modify **existing** arbitraries as it showed [here](https://github.com/KarazinScalaUsersGroup/scala-course-2020/blob/master/src/test/scala/karazin/scala/users/group/classes/homework/arbitraries.scala). Then you need to update all your **existing** tests replacing hints like `abs(...) + 1`, etc with new specific types for positive, non-negative, negative integers as it showed [here](https://github.com/KarazinScalaUsersGroup/scala-course-2020/blob/master/src/test/scala/karazin/scala/users/group/classes/homework/HomeworkSpecification.scala).

#### Set operations
You are challenged to implement tree-like typed set based on characteristic functions.

#### Review the following code
* https://github.com/KarazinScalaUsersGroup/scala-course-2020/blob/master/src/main/scala/karazin/scala/users/group/set/utils.scala
* https://github.com/KarazinScalaUsersGroup/scala-course-2020/blob/master/src/main/scala/karazin/scala/users/group/set/Topic.scala
* https://github.com/KarazinScalaUsersGroup/scala-course-2020/blob/master/src/main/scala/karazin/scala/users/group/set/Hint.scala

Rewrite your solution for set following the idea described [here](https://github.com/KarazinScalaUsersGroup/scala-course-2020/blob/master/src/main/scala/karazin/scala/users/group/set/Topic.scala).
Rewrite all the methods accordingly.
Implement implicit (`given`s) `Ordering` at least for `Int` and `String`.
Rewrite tests accordingly and... good luck.


## Проблемы с подсветкой синтаксиса для Dotty
Проверьте настройки проекта:
![](https://i.imgur.com/Li71dFd.png)

![](https://i.imgur.com/3Aeic62.png)

## Ограничение доступа к форку
Удалите группу `scala-course-2020` из форка, как это показано здесь:
![](https://i.imgur.com/vlQRWD8.png)
