Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/elsys/oop
Browse files Browse the repository at this point in the history
  • Loading branch information
Mario Benov committed Oct 1, 2024
2 parents 4dd413d + 37cb650 commit 7301f1c
Show file tree
Hide file tree
Showing 22 changed files with 716 additions and 81 deletions.
200 changes: 119 additions & 81 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,81 +1,119 @@
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# AWS User-specific
.idea/**/aws.xml

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# SonarLint plugin
.idea/sonarlint/

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

target
*.class
*.out
# Created by https://www.toptal.com/developers/gitignore/api/intellij
# Edit at https://www.toptal.com/developers/gitignore?templates=intellij

### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# AWS User-specific
.idea/**/aws.xml

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# SonarLint plugin
.idea/sonarlint/

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

### Intellij Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721

# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr

# Sonarlint plugin
# https://plugins.jetbrains.com/plugin/7973-sonarlint
.idea/**/sonarlint/

# SonarQube Plugin
# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
.idea/**/sonarIssues.xml

# Markdown Navigator plugin
# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
.idea/**/markdown-navigator.xml
.idea/**/markdown-navigator-enh.xml
.idea/**/markdown-navigator/

# Cache file creation bug
# See https://youtrack.jetbrains.com/issue/JBR-2257
.idea/$CACHE_FILE$

# CodeStream plugin
# https://plugins.jetbrains.com/plugin/12206-codestream
.idea/codestream.xml

# Azure Toolkit for IntelliJ plugin
# https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij
.idea/**/azureSettings.xml

# End of https://www.toptal.com/developers/gitignore/api/intellij

*.class
Binary file not shown.
11 changes: 11 additions & 0 deletions materials/2020-2021/11a/2021-03-22-input/2021-03-22-input.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
44 changes: 44 additions & 0 deletions materials/2020-2021/11a/2021-03-22-input/src/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
// String str1 = "Hello";
// String str2 = "Hello";
//
// String str3 = str1.concat(str2);
// String str4 = str1.concat(str2);
//
// StringBuilder sb = new StringBuilder();
// sb.append("Hello").append(" ").append("World");
//
// System.out.println(str4);
// System.out.println(sb);
//
// System.out.println(args.length);
// for (String arg : args) {
// System.out.println(arg);
// }
//
// InputStreamReader isr = new InputStreamReader(System.in);
//// isr.read
// BufferedReader br = new BufferedReader(isr);
// try {
// String line = br.readLine();
// System.out.println(line);
// int num = Integer.parseInt(line);
// System.out.println(num);
//// line.spl
// } catch (IOException e) {
// e.printStackTrace();
// }

// Scanner sc = new Scanner(System.in);
// System.out.println(sc.nextLine());
// System.out.println(sc.nextInt());

System.out.println(System.console().readLine());
}
}
11 changes: 11 additions & 0 deletions materials/2020-2021/11b/2021-03-22-strings/2021-03-22-strings.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
43 changes: 43 additions & 0 deletions materials/2020-2021/11b/2021-03-22-strings/src/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
/*System.out.println(args.length);
for (String arg : args) {
System.out.println(arg);
}
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
try {
String line = br.readLine();
System.out.println(line);
int num = Integer.parseInt(line);
System.out.println(num);
} catch (IOException e) {
e.printStackTrace();
}*/

// Scanner in = new Scanner(System.in);

// System.out.println(in.nextLine());
// int num = in.nextInt();
// System.out.println(num);

// String line = System.console().readLine();
// System.out.println(line);

// String str1 = "Hello";
// String str2 = "Hello";
// String str3 = str1.concat(str2);

StringBuilder sb = new StringBuilder();
sb.append("Hello").append(" ").append("World");
System.out.println(sb);
}
}
68 changes: 68 additions & 0 deletions materials/2020-2021/exams/exam-1-2/matrix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
1. Дефинирайте клас за **вектор** от геометрията. От тук нататък когато в условието се спомене **вектор** се има в предвид този клас.
- има атрибут цяло число с неговия размер N. Може да се чете, но не и да се пише отвън
- има едномерен динамичен масив от цели числа. Не може да се достъпва отвън
- има единствен конструктор, който получава аргументи размер N и масив. Заделя памет за N на брой елементи и ги чете последователно от подадения масив
- дефинирайте оператор [] за достъпване на елемент от масива по индекс

2. Дефинирайте клас за матрица
- има атрибути цели числа за нейния размер - N за брой редове и M за брой колони
- има едномерен динамичен масив от вектори - всеки вектор представлява една **колона**
- има единствен скрит конструктор с аргументи за размерите. Конструкторът заделя нужната памет за елементите в масива
- има статичен метод `Matrix from_array(int N, int M, int arr)`, който връща инициализирана инстанция на матрица
- има статичен метод `Matrix from_matrix(Matrix other)`, който връща инициализирана инстанция на матрица
- дефинирайте оператор за събиране **+**
- с число - всеки елемент на матрицата се събира с подаденото число
```
| 1 2 3 | | 2 3 4 |
| 4 5 6 | + 1 = | 5 6 7 |
```
- с матрица - всеки елемент на първата матрица се събира със съответния елемент на втората
```
| 1 2 3 | | 7 8 9 | | 8 10 12 |
| 4 5 6 | + | 1 2 3 | = | 5 7 9 |
```
- дефинирайте оператор за изваждане **-**
- с число - от всеки елемент на матрицата се изважда подаденото число
```
| 1 2 3 | | 0 1 2 |
| 4 5 6 | - 1 = | 3 4 5 |
```
- с матрица - от всеки елемент на първата матрица се вади съответният елемент елемент на втората
```
| 1 2 3 | | 7 8 9 | | -6 -6 -6 |
| 4 5 6 | - | 1 2 3 | = | 3 3 3 |
```
- дефинирайте оператор за умножение **\***
- с число - всеки елемент на матрицата се умножава с подаденото число
```
| 1 2 3 | | 2 4 6 |
| 4 5 6 | * 2 = | 8 10 12 |
```
- с матрица - всеки елемент от резултантната матрица представлява сбор от произведенията на съответни елементи в ред на първата и колона на втората матрица. [картинка](https://miro.medium.com/max/1200/1*YGcMQSr0ge_DGn96WnEkZw.png)
```
| 1 2 3 | | 3 | | 3*1 + 3*2 + 3*3 | | 18 |
| 4 5 6 | * | 7 | = | 7*4 + 7*5 + 7*6 | = | 105 |
```

*За умножение е нужно броят **колони** на **първата** матрица да е равен на броя **редове** на **втората** матрица*
- дефинирайте оператор за изход **<<**, който извежда елементите на матрицата във формат
```
| v11 v12 ... v1m |
| v21 v22 ... v2m |
| ... |
| vn1 vn2 ... vnm |
```
- дефинирайте оператор за достъпване по индекс [], който връща връща векторът на подадения индeкс. *my_matrix[3][7] трябва да върне елемента в колона с индекс 3 и ред с индекс 7*
- всички горни методи и оператори да хвърлят изключения при несъвпадащи или нулеви и отрицателни размери

3. Допълнителни:
- имайте минимален брой извиквания на конструктури и копирания на данни при извикване на методи и оператори
- динамичната памет да се почиства и освобождава
- да се обработват хвърляните изключения
- демонстрация на всичко в `main`
- имплементирайте метод транспониране на матрица - завъртане така, че да се разменят редовете и колоните
```
| 1 2 3 | | 1 4 |
| 4 5 6 | => | 2 5 |
| 3 6 |
```
Binary file added materials/2020-2021/exams/exam-1-2/matrix.pdf
Binary file not shown.
Loading

0 comments on commit 7301f1c

Please sign in to comment.