# Setting up the environment
This is step-by-step guide to prepare your working environment to be ready to work on the programming assignments during the course.
## Git installation
### Git instalation tutorials
#### Installing on Ubuntu
```$ sudo apt install git-all```
#### Installing on macOS
Check wether git is already installed
```$ git --version```
If not, download from [here](https://git-scm.com/download/mac) and install.
#### Installing on Windows
Download from [here](https://git-scm.com/download/win) and install.
For vore details visit [en](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git), [ru](https://git-scm.com/book/ru/v2/%D0%92%D0%B2%D0%B5%D0%B4%D0%B5%D0%BD%D0%B8%D0%B5-%D0%A3%D1%81%D1%82%D0%B0%D0%BD%D0%BE%D0%B2%D0%BA%D0%B0-Git), [ua](https://git-scm.com/book/uk/v2/%D0%92%D1%81%D1%82%D1%83%D0%BF-%D0%86%D0%BD%D1%81%D1%82%D0%B0%D0%BB%D1%8F%D1%86%D1%96%D1%8F-Git).
## GitHub
### New account
Create account on https://github.com/
### New repository
Create new Scala repository

You can create public or private repository. If you create the private one then you need to add me to your repository manually.

## IntelliJ Idea Installation
Install the latest __community__ edition.
If you have IntelliJ Idea already installed it's better to remove the older version and install the new one. You can use the previously installed IDE if you use it in a real project as a part of internship or job.
### Downloading
* [Downloading](https://www.jetbrains.com/idea/download/#section=linux) on Ubuntu.
* [Downloading](https://www.jetbrains.com/idea/download/#section=mac) on macOS.
* [Downloading](https://www.jetbrains.com/idea/download/#section=windows) on Windows.
### Installation
* Start installation.
* Accept JetBrains Privacu Policy

* Choose a color theme (personally I do prefere the dark one)

* Click next until `Default plugins` page

* Customize Build Tools
Only __Maven__ must be enabled.

Save Changes and Go Back.
* Customize Version Controls
Only __Git__ must be enabled.

Save Changes and Go Back.
* Swing must be disabled.
* Disable Android by clicking on `Enable`.
* Plugin development must be disabled.
* `Download featured plugin` page

* Install Scala plugin only
* Start using IntelliJ IDEA
### Setting up additional functionality
* Chose `Configure` and then settings

* Type `Reopen` and remove flag from `Reopen project on startup`

## First start and first project
* Create new project

* Chose Scala and sbt

* Name your project as `HelloWorld` (without spaces, each word must be started from a capital letter). Be sure that you use JDK 11+, sbt 1.3+ and Scala 2.13+
* Finish setting up the project.
### Project structure
Review [Introduction to the Standard Directory Layout](https://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html) page
## Adding implementation

* Add new package to `scala` folder by right-mouse-button-click then `new` then `Package`. Name package as `ksugc` (Karazin Scala Users' Group Course)

* Add new Scala class by `new` then `Scala Class`. Name the class as `HelloWorld`
* Add the following code to your class:
```[scala]
package ksugc
object HelloWorld extends App {
println("Hello world!")
}
```
* Build the project by "green hummer" or `Build` the `Build Project`. It may take up to several minutes (depends on the performance of your notebook)

* Run the application by clickin on the "green triangle"

If you faced the error

then rebuild the project and run again. If it didn't help then manually remove `Target` folder then rebuild and run the project.

If all works fine then you'll see

in the console.
* .gitignore
Create `.gitignore` file (with the dot symbol in front) at the top level of the project.

Add following text to the file:
```
*.class
*.log
# sbt specific
.cache/
.history/
.lib/
dist/*
target/
lib_managed/
src_managed/
project/boot/
project/plugins/project/
# Scala-IDE specific
.scala_dependencies
.worksheet
.idea
.idea/
```

## Pushing project to GitHub
* Open terminal and init git repository by `git init` command

* Add all necessary files to the repository (all unnecessary files listed in `.gitignore` won't be added) by `git add .` (dot after `add` is required)

* Make your first commit by `git commit -m "Init repository"`

* Visit your repository's page on GitHub and find the following instructions

Copy the console commands and execute them one by one. If needed add your login (email) and password.
