├── exercises ├── 1 │ ├── exercises │ │ ├── 12-exam │ │ │ └── unique_ptr.cpp │ │ ├── 07-files │ │ │ ├── rle_encoded.txt │ │ │ ├── file.txt │ │ │ ├── rle_string.txt │ │ │ ├── rle_decoded.txt │ │ │ ├── numbers.txt │ │ │ ├── students.bin │ │ │ ├── students2.bin │ │ │ ├── merged.bin │ │ │ └── files.cpp │ │ ├── 10-dynamic-polymorphism-2 │ │ │ └── a.out │ │ ├── 04-headers-and-testing │ │ │ ├── partial_compilation │ │ │ │ ├── world.hpp │ │ │ │ ├── world.cpp │ │ │ │ ├── main.cpp │ │ │ │ ├── greeter.cpp │ │ │ │ ├── greeter.hpp │ │ │ │ └── Makefile │ │ │ └── vector │ │ │ │ └── int_vector.hpp │ │ ├── 05-operator-overloading │ │ │ └── main.cpp │ │ └── 08 - templates │ │ │ └── problems.cpp │ └── bonuses │ │ └── bitmaps │ │ ├── monkas.bmp │ │ ├── monkasGS.bmp │ │ ├── monkasGS2.bmp │ │ ├── 140-300-200-180-example.bmp │ │ └── thumbnail.md ├── 2 │ ├── README.md │ ├── FootballTeamTask.docx │ ├── ConsoleApplication1.cpp │ ├── PolimorphismAndAbstract │ │ ├── Tema15.pdf │ │ ├── Задача 2.docx │ │ ├── Garage.h │ │ ├── Garage.cpp │ │ └── Source.cpp │ ├── PreparationForTest_2 │ │ ├── Задача 1.docx │ │ ├── Classroom.h │ │ └── Relation.h │ ├── week_1_structures │ │ └── Source.cpp │ ├── FinalExercise │ │ ├── Тест ООП (ИС) 2018_19.odt │ │ └── Писмен изпит ООП-13.06.19.odt │ ├── Задача за подготовка за контролно.docx │ ├── MultipleInheritanceVirtualClasses │ │ ├── Tema14.pdf │ │ ├── Задачи 11.05.docx │ │ └── oop_2018_2019_10_lekcia.pdf │ ├── week_11_Inheritance_sample_project │ │ ├── OOP_2018_2019_8_lekcia.pdf │ │ ├── oop_2018_2019_9_lekcia.pdf │ │ ├── SampleDOucmentationStructure.docx │ │ └── sampleProject │ │ │ ├── Students.h │ │ │ ├── Student.h │ │ │ ├── Program.h │ │ │ ├── DBManager.h │ │ │ ├── Students.cpp │ │ │ └── Source.cpp │ ├── week_4_taskWithWebServers │ │ ├── 275606399_743352806652586_7439302660595962570_n.png │ │ ├── WebServer.h │ │ ├── Source.cpp │ │ └── ServerFarm.h │ ├── week_2_IntroductionToClasses │ │ ├── Wallet.h │ │ ├── Source.cpp │ │ ├── Rational.h │ │ ├── Wallet.cpp │ │ └── Rational.cpp │ ├── week_6_friendFuncAndString │ │ ├── Source.cpp │ │ └── String.h │ ├── week_3_big4 │ │ └── Polynome.h │ ├── week_5_tasks │ │ ├── SumAvgCalculator.h │ │ ├── Source.cpp │ │ └── SumAvgCalculator.cpp │ └── week_8_file_read_write+binary │ │ ├── WebServer.h │ │ ├── ServerFarm.h │ │ └── Source.cpp ├── 3 │ └── README.md ├── 4 │ ├── README.md │ ├── week10 │ │ ├── inh.png │ │ └── README.md │ ├── week01 │ │ ├── week01.png │ │ ├── README.md │ │ └── week01.cpp │ ├── week14 │ │ └── tasks.pdf │ ├── week04 │ │ └── dummy.cpp │ ├── week07 │ │ └── README.md │ └── week12 │ │ └── README.md ├── 5 │ └── README.md ├── 6 │ └── README.md ├── 7 │ └── Week-1 │ │ └── README.md └── 8 │ └── README.md ├── lectures ├── 1 │ ├── README.md │ ├── files │ │ ├── products.txt │ │ ├── CMakeLists.txt │ │ └── product.hpp │ ├── struct │ │ ├── students.txt │ │ └── CMakeLists.txt │ ├── streams │ │ └── CMakeLists.txt │ ├── geometry │ │ ├── CMakeLists.txt │ │ └── main.cpp │ ├── rational │ │ └── CMakeLists.txt │ ├── templates │ │ └── CMakeLists.txt │ ├── highorder │ │ └── CMakeLists.txt │ ├── stack │ │ ├── CMakeLists.txt │ │ ├── abstract_stack.hpp │ │ ├── stack.cpp │ │ └── stack.hpp │ └── player │ │ ├── CMakeLists.txt │ │ ├── printable.hpp │ │ ├── bot.cpp │ │ ├── boss.hpp │ │ ├── bot.hpp │ │ ├── boss.cpp │ │ ├── ai.hpp │ │ ├── ai.cpp │ │ ├── player.hpp │ │ ├── hero.hpp │ │ └── superhero.hpp └── 2 │ └── README.md ├── .gitignore └── practicum ├── 1 └── README.md ├── 2 ├── README.md ├── 08-files │ ├── Week08.pdf │ └── solutions │ │ ├── spacecrafts │ │ └── Spacecraft.h │ │ └── stars │ │ ├── Source.cpp │ │ └── Star.h ├── 01-struct │ ├── week01.pdf │ └── solutions │ │ └── problems07-09.cpp ├── 11-polymorphism │ ├── Week11.pdf │ └── solutions │ │ ├── Point2D.hpp │ │ ├── MathFormulas.hpp │ │ ├── Triangle.h │ │ ├── Circle.cpp │ │ ├── Circle.h │ │ ├── Rectangle.h │ │ ├── Shape.h │ │ ├── Rectangle.cpp │ │ ├── Triangle.cpp │ │ └── ShapeContainer.h ├── 02-class-constructor │ ├── week02.pdf │ ├── Week02-Additional-Tasks.pdf │ └── solutions │ │ ├── problem1.cpp │ │ ├── Beer.h │ │ └── Beer.cpp ├── 03-big-four │ ├── Week03-BigFour.pdf │ └── solutions │ │ └── Vector.h ├── 12-inheritance-practice │ └── Week12.pdf ├── 04-big-four-practice │ └── Week04-Task.pdf ├── 05-overloading-operators │ ├── week05.pdf │ └── solutions │ │ └── Virus.h ├── 09-templates │ ├── Week09 - Templates.pdf │ └── solutions │ │ ├── point.h │ │ ├── point.cpp │ │ └── order.cpp ├── 10-inheritance-and-templates │ ├── Week10.pdf │ └── solutions │ │ ├── soldier.h │ │ └── commander.h └── 06-overloading-and-big4-practice │ └── week06.pdf ├── 3 ├── README.md ├── 13 - 27.05.2022 │ ├── JSON.hpp │ ├── JSONEntry.hpp │ ├── JSONString.hpp │ ├── JSONNumber.hpp │ ├── JSONObj.hpp │ ├── main.cpp │ └── JSONArr.hpp ├── 04 - 18.03.2022 │ ├── README.md │ └── Task 1 │ │ └── Vector3D.h ├── 03 - 11.03.2022 │ └── README.md ├── 05 - 25.03.2022 │ └── README.md ├── 10 - 13.05.2022 │ ├── main.cpp │ ├── Axe.h │ ├── melee.h │ ├── Ranged.h │ ├── Japanka.h │ ├── Axe.cpp │ ├── README.md │ ├── Melee.cpp │ ├── Ranged.cpp │ ├── Japanka.cpp │ └── Weapon.h ├── 14 - 03.06.2022 │ ├── Dish.h │ ├── SurfNTurf.h │ ├── main.cpp │ ├── SeafoodDish.h │ ├── MeatDish.h │ └── MeatDish.cpp ├── 02 - 04.03.2022 │ └── Task 1 │ │ ├── worker.hpp │ │ ├── company.hpp │ │ ├── team.hpp │ │ └── main.cpp ├── 06, 07 - 08.04.2022 │ ├── Task 1 & Task 2 │ │ ├── Event.hpp │ │ ├── Schedule.hpp │ │ └── DateTime.hpp │ └── README.md └── 11, 12 - 19 & 20.05.2022 │ └── main.cpp ├── 4 ├── README.md ├── Week07-Files │ ├── snippets │ │ ├── 01-writingToTextFile │ │ │ ├── tempInfo.txt │ │ │ ├── importantInfo.txt │ │ │ ├── money.h │ │ │ └── money.cpp │ │ ├── 03-commandLineArguments │ │ │ ├── machkai.txt │ │ │ └── main.cpp │ │ ├── 02-readingFromTextFile │ │ │ ├── 02-04-readingObjects │ │ │ │ ├── people.txt │ │ │ │ ├── person.h │ │ │ │ ├── person.cpp │ │ │ │ └── main.cpp │ │ │ ├── dadJokes.txt │ │ │ ├── 02-03-charByChar.cpp │ │ │ ├── 02-01-wordByWord.cpp │ │ │ └── 02-02-lineByLine.cpp │ │ └── 04-binaryFiles │ │ │ └── 04-02-objects │ │ │ ├── person.h │ │ │ └── person.cpp │ └── lab │ │ └── solutions │ │ ├── princesa.txt │ │ ├── task04.cpp │ │ ├── task01.cpp │ │ └── task02.cpp ├── Week06-FriendFunctionsAndGitHub │ ├── snippets │ │ ├── 02-operatorsInAndOut │ │ │ ├── dummy.txt │ │ │ ├── dummy2.txt │ │ │ ├── main.cpp │ │ │ ├── money.h │ │ │ └── money.cpp │ │ └── 01-moreArithmeticOperators │ │ │ ├── main.cpp │ │ │ └── money.h │ └── lab │ │ └── solutions │ │ ├── Task01 │ │ ├── main.cpp │ │ └── Time.h │ │ └── Task02 │ │ └── main.cpp ├── Week09-StaticAndTemplates │ ├── lab │ │ └── solutions │ │ │ ├── charList.txt │ │ │ ├── consultantUtils.h │ │ │ ├── computerShop.h │ │ │ ├── task01.cpp │ │ │ └── consultantUtils.cpp │ └── snippets │ │ ├── 06-multipleTemplateArguments.cpp │ │ ├── 01-staticVariables.cpp │ │ └── 03-singleton.cpp ├── Week10-Inheritance │ └── lab │ │ └── solution │ │ ├── Main.cpp │ │ ├── ServingType.h │ │ ├── Food.h │ │ ├── Drink.h │ │ ├── Alcohol.h │ │ ├── MenuItem.h │ │ ├── Engine.h │ │ ├── Drink.cpp │ │ ├── Food.cpp │ │ ├── MenuItem.cpp │ │ └── Alcohol.cpp ├── Week14-UnitTests │ ├── snippets │ │ ├── 04-TDD │ │ │ ├── factorielSolver.h │ │ │ ├── factorielSolver.cpp │ │ │ └── tests.cpp │ │ ├── 02-MultipleTestFiles │ │ │ ├── classA.h │ │ │ ├── classB.h │ │ │ ├── testsA.cpp │ │ │ └── testsB.cpp │ │ ├── 01-OurFirstUniTests │ │ │ ├── calculator.h │ │ │ ├── calculator.cpp │ │ │ └── tests.cpp │ │ └── 00-customException │ │ │ └── customException.cpp │ └── lab │ │ └── README.md ├── Week11-AbstractClassesAndPolymorphism │ ├── lab │ │ └── solution │ │ │ ├── Main.cpp │ │ │ ├── TableType.h │ │ │ ├── ChairType.h │ │ │ ├── Utility.h │ │ │ ├── Utility.cpp │ │ │ ├── Bed.h │ │ │ ├── Chair.h │ │ │ ├── Table.h │ │ │ ├── Bed.cpp │ │ │ ├── FurnitureHouse.h │ │ │ └── Furniture.h │ └── snippets │ │ └── a.out ├── Week04-EnumsAndOperatorOveloading │ ├── lab │ │ └── solution │ │ │ ├── taskCategory.h │ │ │ ├── date.h │ │ │ ├── taskManager.h │ │ │ └── task.h │ └── snippets │ │ ├── 02-enums │ │ ├── main.cpp │ │ ├── bookType.h │ │ ├── book.h │ │ └── book.cpp │ │ ├── 03-operatorOverloading │ │ ├── money.h │ │ ├── main.cpp │ │ └── money.cpp │ │ └── 01-separateCompilation │ │ ├── book.h │ │ ├── library.h │ │ ├── book.cpp │ │ └── main.cpp ├── Week12-MultiInheritance │ ├── lab │ │ ├── solution │ │ │ ├── Person.cpp │ │ │ ├── Assistant.cpp │ │ │ ├── Student.cpp │ │ │ ├── Teacher.cpp │ │ │ ├── Assistant.h │ │ │ ├── Student.h │ │ │ ├── Teacher.h │ │ │ ├── Person.h │ │ │ └── Main.cpp │ │ └── README.md │ └── snippets │ │ └── 04-multiInheritance.cpp ├── Week05-MoreOperatorOverloading │ └── snippets │ │ ├── 01-operatorPlus │ │ ├── main.cpp │ │ └── money.h │ │ └── 02-operatorMinus │ │ ├── main.cpp │ │ └── money.h ├── Week08-MidExam1Preparation │ └── solutions │ │ ├── main.cpp │ │ └── University.h ├── Week03-ClassesAndRuleOf0-3 │ └── snippets │ │ └── 01-structVsClass.cpp ├── Week02-MoreStructs │ └── snippets │ │ ├── 02-initializingViaMethod.cpp │ │ ├── 04-defaultConstructor.cpp │ │ └── 01-ourFirstMethod.cpp └── Week01-Structs │ └── snippets │ └── 01-structCreation.cpp ├── 5 └── README.md ├── 6 ├── README.md ├── week2 │ └── файлове.pdf └── week1 │ └── Структури. Декалрация и използване на структури..pdf ├── 7 ├── Week-02-Struct │ └── Solutions │ │ └── Task-2 │ │ ├── Task-2.cpp │ │ └── Warrior.h ├── README.md ├── Week-10-Inheritance │ └── Solutions │ │ ├── Task3 │ │ ├── insufficent_fuel.cpp │ │ ├── FuelTank.h │ │ ├── Engine.h │ │ ├── Engine.cpp │ │ ├── insufficent_fuel.h │ │ ├── FuelTank.cpp │ │ └── CarPart.h │ │ └── Task1 │ │ ├── Source.cpp │ │ ├── Animal.h │ │ ├── Pet.h │ │ ├── Animal.cpp │ │ └── Pet.cpp ├── Week-1 │ ├── ClassWork │ │ ├── Task-1 │ │ │ ├── a.out │ │ │ └── source │ │ ├── Task-2 │ │ │ └── a.out │ │ └── question.txt │ └── Solutions │ │ ├── Task-2 │ │ └── Gradebook.h │ │ └── Task-3 │ │ └── StudentsBook.h ├── Additional-01 │ └── Classwork │ │ ├── Task-2 │ │ ├── TaxiCentral.cpp │ │ ├── Source.cpp │ │ ├── Order.h │ │ ├── TaxiDriver.h │ │ └── TaxiCentral.h │ │ ├── Task-3 │ │ ├── main.cpp │ │ ├── BookStore.h │ │ └── Utils.h │ │ └── Task-1 │ │ └── Bus.h ├── Week-03-Classes │ ├── Theory │ │ ├── Theory.md │ │ └── 5. Delegating constructors.cpp │ ├── 2-Waffles │ │ └── Source.cpp │ └── 1-Scientists │ │ └── Source.cpp ├── Week-09-Static-and-Templates │ └── Separate Compilation │ │ ├── Source.cpp │ │ ├── Array.h │ │ └── Array.inc ├── Additional-02 │ └── Suitcase │ │ ├── Person.h │ │ ├── Suit.h │ │ ├── Pants.h │ │ ├── Dress.h │ │ ├── ClothingItem.h │ │ └── main.cpp ├── Week-05-Big-four │ ├── Classwork │ │ ├── source.cpp │ │ └── MyString.h │ ├── Assignments.md │ └── Theory │ │ ├── Overloading assignment operator.cpp │ │ └── Const with classes.cpp ├── Week-07-Streams-Files │ └── Task-1 │ │ └── Source.cpp ├── Week-12-Polymorphism │ └── Task-1 │ │ ├── Source.cpp │ │ ├── Rectangle.h │ │ ├── Circle.h │ │ ├── Rhombus.h │ │ ├── ShapeContainer.h │ │ └── Triangle.h └── Week-06-Operator-Overloading │ └── Theory & Examples │ └── main.cpp └── 8 └── README.md /exercises/1/exercises/12-exam/unique_ptr.cpp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /exercises/1/exercises/07-files/rle_encoded.txt: -------------------------------------------------------------------------------- 1 | 13a5b3a13cx3y -------------------------------------------------------------------------------- /lectures/1/README.md: -------------------------------------------------------------------------------- 1 | # Материали към лекциите на 1 поток 2 | -------------------------------------------------------------------------------- /lectures/2/README.md: -------------------------------------------------------------------------------- 1 | # Материали към лекциите на 1 поток 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.code-workspace 2 | .* 3 | !.gitignore 4 | build/ 5 | -------------------------------------------------------------------------------- /practicum/7/Week-02-Struct/Solutions/Task-2/Task-2.cpp: -------------------------------------------------------------------------------- 1 | #include -------------------------------------------------------------------------------- /exercises/1/exercises/07-files/file.txt: -------------------------------------------------------------------------------- 1 | Duma 2ra Duma malka duma GOLQMA DUMA -------------------------------------------------------------------------------- /exercises/2/README.md: -------------------------------------------------------------------------------- 1 | # Материали към семинарните упражнения на 2 група 2 | -------------------------------------------------------------------------------- /exercises/3/README.md: -------------------------------------------------------------------------------- 1 | # Материали към семинарните упражнения на 3 група 2 | -------------------------------------------------------------------------------- /exercises/4/README.md: -------------------------------------------------------------------------------- 1 | # Материали към семинарните упражнения на 4 група 2 | -------------------------------------------------------------------------------- /exercises/5/README.md: -------------------------------------------------------------------------------- 1 | # Материали към семинарните упражнения на 5 група 2 | -------------------------------------------------------------------------------- /exercises/6/README.md: -------------------------------------------------------------------------------- 1 | # Материали към семинарните упражнения на 6 група 2 | -------------------------------------------------------------------------------- /exercises/8/README.md: -------------------------------------------------------------------------------- 1 | # Материали към семинарните упражнения на 8 група 2 | -------------------------------------------------------------------------------- /practicum/1/README.md: -------------------------------------------------------------------------------- 1 | # Материали към практическите упражнения на 1 група 2 | -------------------------------------------------------------------------------- /practicum/2/README.md: -------------------------------------------------------------------------------- 1 | # Материали към практическите упражнения на 2 група 2 | -------------------------------------------------------------------------------- /practicum/3/README.md: -------------------------------------------------------------------------------- 1 | # Материали към практическите упражнения на 3 група 2 | -------------------------------------------------------------------------------- /practicum/4/README.md: -------------------------------------------------------------------------------- 1 | # Материали към практическите упражнения на 4 група 2 | -------------------------------------------------------------------------------- /practicum/5/README.md: -------------------------------------------------------------------------------- 1 | # Материали към практическите упражнения на 5 група 2 | -------------------------------------------------------------------------------- /practicum/6/README.md: -------------------------------------------------------------------------------- 1 | # Материали към практическите упражнения на 6 група 2 | -------------------------------------------------------------------------------- /practicum/7/README.md: -------------------------------------------------------------------------------- 1 | # Материали към практическите упражнения на 7 група 2 | -------------------------------------------------------------------------------- /practicum/8/README.md: -------------------------------------------------------------------------------- 1 | # Материали към практическите упражнения на 8 група 2 | -------------------------------------------------------------------------------- /exercises/1/exercises/07-files/rle_string.txt: -------------------------------------------------------------------------------- 1 | aaaaaaaaaaaaabbbbbaaacccccccccccccxyyy -------------------------------------------------------------------------------- /exercises/1/exercises/07-files/rle_decoded.txt: -------------------------------------------------------------------------------- 1 | aaaaaaaaaaaaabbbbbaaacccccccccccccxyyy -------------------------------------------------------------------------------- /practicum/4/Week07-Files/snippets/01-writingToTextFile/tempInfo.txt: -------------------------------------------------------------------------------- 1 | Neshto malovazhno -------------------------------------------------------------------------------- /practicum/4/Week06-FriendFunctionsAndGitHub/snippets/02-operatorsInAndOut/dummy.txt: -------------------------------------------------------------------------------- 1 | example -------------------------------------------------------------------------------- /practicum/4/Week06-FriendFunctionsAndGitHub/snippets/02-operatorsInAndOut/dummy2.txt: -------------------------------------------------------------------------------- 1 | alo, da -------------------------------------------------------------------------------- /exercises/1/exercises/07-files/numbers.txt: -------------------------------------------------------------------------------- 1 | go6o -------------------------------------------------------------------------------- /lectures/1/files/products.txt: -------------------------------------------------------------------------------- 1 | 3 2 | 101 29.9 Хубав стол 3 | 103 98.9 Маса 4 | 110 5.5 Чиния 5 | -------------------------------------------------------------------------------- /practicum/7/Week-10-Inheritance/Solutions/Task3/insufficent_fuel.cpp: -------------------------------------------------------------------------------- 1 | #include "insufficent_fuel.h" 2 | -------------------------------------------------------------------------------- /exercises/4/week10/inh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triffon/oop-2021-22/HEAD/exercises/4/week10/inh.png -------------------------------------------------------------------------------- /exercises/4/week01/week01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triffon/oop-2021-22/HEAD/exercises/4/week01/week01.png -------------------------------------------------------------------------------- /exercises/4/week14/tasks.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triffon/oop-2021-22/HEAD/exercises/4/week14/tasks.pdf -------------------------------------------------------------------------------- /practicum/6/week2/файлове.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triffon/oop-2021-22/HEAD/practicum/6/week2/файлове.pdf -------------------------------------------------------------------------------- /practicum/2/08-files/Week08.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triffon/oop-2021-22/HEAD/practicum/2/08-files/Week08.pdf -------------------------------------------------------------------------------- /exercises/2/FootballTeamTask.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triffon/oop-2021-22/HEAD/exercises/2/FootballTeamTask.docx -------------------------------------------------------------------------------- /practicum/2/01-struct/week01.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triffon/oop-2021-22/HEAD/practicum/2/01-struct/week01.pdf -------------------------------------------------------------------------------- /practicum/4/Week07-Files/snippets/03-commandLineArguments/machkai.txt: -------------------------------------------------------------------------------- 1 | Machkai 2 | Come on 3 | Vamos 4 | Chum jetze 5 | Pojd -------------------------------------------------------------------------------- /exercises/2/ConsoleApplication1.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triffon/oop-2021-22/HEAD/exercises/2/ConsoleApplication1.cpp -------------------------------------------------------------------------------- /practicum/4/Week07-Files/snippets/01-writingToTextFile/importantInfo.txt: -------------------------------------------------------------------------------- 1 | My name is Peter, I am neither Pavel nor Petko 2 | 3 | -------------------------------------------------------------------------------- /exercises/1/bonuses/bitmaps/monkas.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triffon/oop-2021-22/HEAD/exercises/1/bonuses/bitmaps/monkas.bmp -------------------------------------------------------------------------------- /practicum/2/11-polymorphism/Week11.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triffon/oop-2021-22/HEAD/practicum/2/11-polymorphism/Week11.pdf -------------------------------------------------------------------------------- /exercises/1/bonuses/bitmaps/monkasGS.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triffon/oop-2021-22/HEAD/exercises/1/bonuses/bitmaps/monkasGS.bmp -------------------------------------------------------------------------------- /exercises/1/bonuses/bitmaps/monkasGS2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triffon/oop-2021-22/HEAD/exercises/1/bonuses/bitmaps/monkasGS2.bmp -------------------------------------------------------------------------------- /practicum/7/Week-1/ClassWork/Task-1/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triffon/oop-2021-22/HEAD/practicum/7/Week-1/ClassWork/Task-1/a.out -------------------------------------------------------------------------------- /practicum/7/Week-1/ClassWork/Task-2/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triffon/oop-2021-22/HEAD/practicum/7/Week-1/ClassWork/Task-2/a.out -------------------------------------------------------------------------------- /practicum/2/02-class-constructor/week02.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triffon/oop-2021-22/HEAD/practicum/2/02-class-constructor/week02.pdf -------------------------------------------------------------------------------- /practicum/2/03-big-four/Week03-BigFour.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triffon/oop-2021-22/HEAD/practicum/2/03-big-four/Week03-BigFour.pdf -------------------------------------------------------------------------------- /practicum/7/Week-1/ClassWork/Task-1/source: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triffon/oop-2021-22/HEAD/practicum/7/Week-1/ClassWork/Task-1/source -------------------------------------------------------------------------------- /exercises/2/PolimorphismAndAbstract/Tema15.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triffon/oop-2021-22/HEAD/exercises/2/PolimorphismAndAbstract/Tema15.pdf -------------------------------------------------------------------------------- /exercises/2/PreparationForTest_2/Задача 1.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triffon/oop-2021-22/HEAD/exercises/2/PreparationForTest_2/Задача 1.docx -------------------------------------------------------------------------------- /exercises/2/week_1_structures/Source.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Cup.h" 3 | 4 | int main() { 5 | test(); 6 | 7 | return 0; 8 | } -------------------------------------------------------------------------------- /lectures/1/struct/students.txt: -------------------------------------------------------------------------------- 1 | 3 2 | Ivan Ivanov 3 | 1 4 | 5.75 5 | Stefani Stefanova 6 | 1 7 | 6 8 | Petar Petrov 9 | 2 10 | 5.25 11 | -------------------------------------------------------------------------------- /practicum/2/12-inheritance-practice/Week12.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triffon/oop-2021-22/HEAD/practicum/2/12-inheritance-practice/Week12.pdf -------------------------------------------------------------------------------- /exercises/2/PolimorphismAndAbstract/Задача 2.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triffon/oop-2021-22/HEAD/exercises/2/PolimorphismAndAbstract/Задача 2.docx -------------------------------------------------------------------------------- /practicum/2/04-big-four-practice/Week04-Task.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triffon/oop-2021-22/HEAD/practicum/2/04-big-four-practice/Week04-Task.pdf -------------------------------------------------------------------------------- /practicum/2/05-overloading-operators/week05.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triffon/oop-2021-22/HEAD/practicum/2/05-overloading-operators/week05.pdf -------------------------------------------------------------------------------- /practicum/2/09-templates/Week09 - Templates.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triffon/oop-2021-22/HEAD/practicum/2/09-templates/Week09 - Templates.pdf -------------------------------------------------------------------------------- /exercises/2/FinalExercise/Тест ООП (ИС) 2018_19.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triffon/oop-2021-22/HEAD/exercises/2/FinalExercise/Тест ООП (ИС) 2018_19.odt -------------------------------------------------------------------------------- /exercises/2/Задача за подготовка за контролно.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triffon/oop-2021-22/HEAD/exercises/2/Задача за подготовка за контролно.docx -------------------------------------------------------------------------------- /practicum/2/10-inheritance-and-templates/Week10.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triffon/oop-2021-22/HEAD/practicum/2/10-inheritance-and-templates/Week10.pdf -------------------------------------------------------------------------------- /practicum/4/Week09-StaticAndTemplates/lab/solutions/charList.txt: -------------------------------------------------------------------------------- 1 | 43 2 | a b c c c d e b a f g h h i j k l m n n n o o o p q r s t u v w x y z z z p p i j k l -------------------------------------------------------------------------------- /practicum/4/Week10-Inheritance/lab/solution/Main.cpp: -------------------------------------------------------------------------------- 1 | #include "Engine.h" 2 | 3 | int main() { 4 | Engine::getInstance().run(); 5 | 6 | return 0; 7 | } -------------------------------------------------------------------------------- /exercises/1/exercises/10-dynamic-polymorphism-2/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triffon/oop-2021-22/HEAD/exercises/1/exercises/10-dynamic-polymorphism-2/a.out -------------------------------------------------------------------------------- /exercises/1/bonuses/bitmaps/140-300-200-180-example.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triffon/oop-2021-22/HEAD/exercises/1/bonuses/bitmaps/140-300-200-180-example.bmp -------------------------------------------------------------------------------- /exercises/2/FinalExercise/Писмен изпит ООП-13.06.19.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triffon/oop-2021-22/HEAD/exercises/2/FinalExercise/Писмен изпит ООП-13.06.19.odt -------------------------------------------------------------------------------- /exercises/2/MultipleInheritanceVirtualClasses/Tema14.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triffon/oop-2021-22/HEAD/exercises/2/MultipleInheritanceVirtualClasses/Tema14.pdf -------------------------------------------------------------------------------- /practicum/2/06-overloading-and-big4-practice/week06.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triffon/oop-2021-22/HEAD/practicum/2/06-overloading-and-big4-practice/week06.pdf -------------------------------------------------------------------------------- /practicum/3/13 - 27.05.2022/JSON.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "JSONArr.hpp" 3 | #include "JSONNumber.hpp" 4 | #include "JSONObj.hpp" 5 | #include "JSONString.hpp" 6 | -------------------------------------------------------------------------------- /practicum/4/Week14-UnitTests/snippets/04-TDD/factorielSolver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class FactorielSolver 4 | { 5 | public: 6 | long long solve(long long n); 7 | }; -------------------------------------------------------------------------------- /exercises/1/exercises/04-headers-and-testing/partial_compilation/world.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class World 4 | { 5 | public: 6 | const char* name() const; 7 | }; 8 | -------------------------------------------------------------------------------- /practicum/7/Additional-01/Classwork/Task-2/TaxiCentral.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triffon/oop-2021-22/HEAD/practicum/7/Additional-01/Classwork/Task-2/TaxiCentral.cpp -------------------------------------------------------------------------------- /exercises/1/exercises/04-headers-and-testing/partial_compilation/world.cpp: -------------------------------------------------------------------------------- 1 | #include "world.hpp" 2 | 3 | const char * World::name() const 4 | { 5 | return "FMI"; 6 | } 7 | -------------------------------------------------------------------------------- /practicum/2/02-class-constructor/Week02-Additional-Tasks.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triffon/oop-2021-22/HEAD/practicum/2/02-class-constructor/Week02-Additional-Tasks.pdf -------------------------------------------------------------------------------- /practicum/4/Week11-AbstractClassesAndPolymorphism/lab/solution/Main.cpp: -------------------------------------------------------------------------------- 1 | #include "Engine.h" 2 | 3 | int main() { 4 | Engine::getInstance().run(); 5 | 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /exercises/2/MultipleInheritanceVirtualClasses/Задачи 11.05.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triffon/oop-2021-22/HEAD/exercises/2/MultipleInheritanceVirtualClasses/Задачи 11.05.docx -------------------------------------------------------------------------------- /practicum/4/Week11-AbstractClassesAndPolymorphism/snippets/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triffon/oop-2021-22/HEAD/practicum/4/Week11-AbstractClassesAndPolymorphism/snippets/a.out -------------------------------------------------------------------------------- /practicum/3/13 - 27.05.2022/JSONEntry.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | struct JSONEntry { 5 | virtual void print(std::ostream &) = 0; 6 | virtual ~JSONEntry() {} 7 | }; -------------------------------------------------------------------------------- /practicum/4/Week07-Files/snippets/02-readingFromTextFile/02-04-readingObjects/people.txt: -------------------------------------------------------------------------------- 1 | Lyuben Georgiev 20 2 | Peter Kolev 20 3 | Stella Petrova 52 4 | Gabriela Izvorska 12 5 | Milen Ivanov 72 -------------------------------------------------------------------------------- /practicum/6/week1/Структури. Декалрация и използване на структури..pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triffon/oop-2021-22/HEAD/practicum/6/week1/Структури. Декалрация и използване на структури..pdf -------------------------------------------------------------------------------- /practicum/7/Week-03-Classes/Theory/Theory.md: -------------------------------------------------------------------------------- 1 | # Access modifiers: 2 | 3 | - public -> can access everything outside of the class, same as structure 4 | - private -> only accessible withing the class -------------------------------------------------------------------------------- /exercises/2/MultipleInheritanceVirtualClasses/oop_2018_2019_10_lekcia.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triffon/oop-2021-22/HEAD/exercises/2/MultipleInheritanceVirtualClasses/oop_2018_2019_10_lekcia.pdf -------------------------------------------------------------------------------- /exercises/2/week_11_Inheritance_sample_project/OOP_2018_2019_8_lekcia.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triffon/oop-2021-22/HEAD/exercises/2/week_11_Inheritance_sample_project/OOP_2018_2019_8_lekcia.pdf -------------------------------------------------------------------------------- /exercises/2/week_11_Inheritance_sample_project/oop_2018_2019_9_lekcia.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triffon/oop-2021-22/HEAD/exercises/2/week_11_Inheritance_sample_project/oop_2018_2019_9_lekcia.pdf -------------------------------------------------------------------------------- /exercises/1/exercises/07-files/students.bin: -------------------------------------------------------------------------------- 1 | pe6oivanmaria -------------------------------------------------------------------------------- /practicum/3/04 - 18.03.2022/README.md: -------------------------------------------------------------------------------- 1 | # Задачи за ООП практикум на 3та група - 04.03.2022 2 | 3 | ## Задача 1 4 | Да се дефинира клас `Vector3D` с подходящи функции и да се напишат тестове за функционалността му. -------------------------------------------------------------------------------- /exercises/2/week_11_Inheritance_sample_project/SampleDOucmentationStructure.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triffon/oop-2021-22/HEAD/exercises/2/week_11_Inheritance_sample_project/SampleDOucmentationStructure.docx -------------------------------------------------------------------------------- /practicum/3/03 - 11.03.2022/README.md: -------------------------------------------------------------------------------- 1 | # Задачи за ООП практикум на 3та група - 11.03.2022 2 | 3 | Довършвахме [**Задача 1**](https://github.com/triffon/oop-2021-22/tree/main/practicum/3/02%20-%2004.03.2022) от миналия път. -------------------------------------------------------------------------------- /exercises/1/exercises/04-headers-and-testing/partial_compilation/main.cpp: -------------------------------------------------------------------------------- 1 | #include "greeter.hpp" 2 | #include 3 | 4 | int main() 5 | { 6 | Greeter g; 7 | g.print(); 8 | 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /practicum/2/02-class-constructor/solutions/problem1.cpp: -------------------------------------------------------------------------------- 1 | #include "Beer.h" 2 | 3 | int main() 4 | { 5 | int a = 10; 6 | 7 | Beer beer1("Heineken", 500); 8 | 9 | beer1.print(); 10 | 11 | return 0; 12 | } -------------------------------------------------------------------------------- /practicum/3/05 - 25.03.2022/README.md: -------------------------------------------------------------------------------- 1 | # Задачи за ООП практикум на 3та група - 25.03.2022 2 | 3 | Довършвахме [**Задача 1**](https://github.com/triffon/oop-2021-22/tree/main/practicum/3/02%20-%2004.03.2022) от втората седмица. -------------------------------------------------------------------------------- /practicum/4/Week04-EnumsAndOperatorOveloading/lab/solution/taskCategory.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | enum class TaskCategory 4 | { 5 | UNKNOWN, 6 | UNIVERSITY, 7 | WORK, 8 | FOR_HOME, 9 | OTHER 10 | }; -------------------------------------------------------------------------------- /exercises/2/week_4_taskWithWebServers/275606399_743352806652586_7439302660595962570_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triffon/oop-2021-22/HEAD/exercises/2/week_4_taskWithWebServers/275606399_743352806652586_7439302660595962570_n.png -------------------------------------------------------------------------------- /practicum/4/Week04-EnumsAndOperatorOveloading/snippets/02-enums/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "book.h" 3 | 4 | int main () 5 | { 6 | Book book("Harry Potter", 2001, BookType::FANTASY); 7 | 8 | return 0; 9 | } -------------------------------------------------------------------------------- /practicum/4/Week10-Inheritance/lab/solution/ServingType.h: -------------------------------------------------------------------------------- 1 | #ifndef SERVINGTYPE_H 2 | #define SERVINGTYPE_H 3 | 4 | enum class ServingType { 5 | GLASS, 6 | JUG, 7 | BOTTLE 8 | }; 9 | 10 | #endif // !SERVINGTYPE_H 11 | -------------------------------------------------------------------------------- /exercises/1/exercises/04-headers-and-testing/partial_compilation/greeter.cpp: -------------------------------------------------------------------------------- 1 | #include "greeter.hpp" 2 | 3 | #include 4 | 5 | void Greeter::print() const 6 | { 7 | std::cout << "Zdr, " << m_world.name() << '\n'; 8 | } 9 | -------------------------------------------------------------------------------- /practicum/2/11-polymorphism/solutions/Point2D.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | struct Point2D 5 | { 6 | double x; 7 | double y; 8 | 9 | Point2D(double _x = 0, double _y = 0) : x(_x), y(_y) { } 10 | }; 11 | -------------------------------------------------------------------------------- /practicum/4/Week07-Files/lab/solutions/princesa.txt: -------------------------------------------------------------------------------- 1 | Prepechena filiq s kaima se naricha strandzhanka i tova ne podlezhi na komentar. 2 | Sinut na strandzhanka Diana se kazva Harry. 3 | Princ Karl i strandzhanka Klara krali klarineti... 4 | -------------------------------------------------------------------------------- /practicum/4/Week11-AbstractClassesAndPolymorphism/lab/solution/TableType.h: -------------------------------------------------------------------------------- 1 | #ifndef TABLETYPE_H 2 | #define TABLETYPE_H 3 | 4 | enum class TableType { 5 | LIVING_ROOM = 0, 6 | KITCHEN = 1 7 | }; 8 | 9 | #endif // !TABLETYPE_H 10 | -------------------------------------------------------------------------------- /practicum/7/Week-09-Static-and-Templates/Separate Compilation/Source.cpp: -------------------------------------------------------------------------------- 1 | #include "Array.h" 2 | 3 | int main() { 4 | Array arr; 5 | 6 | arr.add(5); 7 | arr.print(); 8 | 9 | Array arr2; 10 | 11 | return 0; 12 | } -------------------------------------------------------------------------------- /practicum/4/Week12-MultiInheritance/lab/solution/Person.cpp: -------------------------------------------------------------------------------- 1 | #include "Person.h" 2 | 3 | Person::Person(std::string_view name) 4 | : m_name(name) { 5 | } 6 | 7 | std::string_view Person::getName() const { 8 | return m_name; 9 | } 10 | -------------------------------------------------------------------------------- /exercises/1/exercises/04-headers-and-testing/partial_compilation/greeter.hpp: -------------------------------------------------------------------------------- 1 | #include "world.hpp" 2 | 3 | #pragma once 4 | 5 | class Greeter 6 | { 7 | public: 8 | void print() const; 9 | private: 10 | World m_world; 11 | }; 12 | -------------------------------------------------------------------------------- /exercises/1/exercises/05-operator-overloading/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "rational.hpp" 3 | 4 | int main() 5 | { 6 | rational x, y; 7 | std::cin >> x >> y; 8 | 9 | std::cout << x << ' ' << y; 10 | return 0; 11 | } -------------------------------------------------------------------------------- /practicum/4/Week11-AbstractClassesAndPolymorphism/lab/solution/ChairType.h: -------------------------------------------------------------------------------- 1 | #ifndef CHAIRTYPE_H 2 | #define CHAIRTYPE_H 3 | 4 | enum class ChairType { 5 | WOODEN = 0, 6 | METAL = 1, 7 | PLASTIC = 2 8 | }; 9 | 10 | #endif // !CHAIRTYPE_H 11 | -------------------------------------------------------------------------------- /practicum/4/Week12-MultiInheritance/lab/solution/Assistant.cpp: -------------------------------------------------------------------------------- 1 | #include "Assistant.h" 2 | 3 | Assistant::Assistant(std::string_view name, const int number, const double salary) 4 | : Student(name, number), Teacher(name, salary), Person(name) { 5 | } 6 | -------------------------------------------------------------------------------- /practicum/7/Week-10-Inheritance/Solutions/Task1/Source.cpp: -------------------------------------------------------------------------------- 1 | #include "Pet.h" 2 | 3 | int main() { 4 | Pet a("Gosho", 13, "mitko", 897221543); 5 | Pet b("Pesho", 10, "dancho", 997651243); 6 | 7 | a = b; 8 | a.print(); 9 | 10 | return 0; 11 | } -------------------------------------------------------------------------------- /practicum/4/Week14-UnitTests/snippets/02-MultipleTestFiles/classA.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class A 4 | { 5 | public: 6 | int f() 7 | { 8 | return 5; 9 | } 10 | 11 | char g() 12 | { 13 | return 'P'; 14 | } 15 | }; -------------------------------------------------------------------------------- /practicum/4/Week14-UnitTests/snippets/02-MultipleTestFiles/classB.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class B 4 | { 5 | public: 6 | int f() 7 | { 8 | return 7; 9 | } 10 | 11 | char g() 12 | { 13 | return 'L'; 14 | } 15 | }; -------------------------------------------------------------------------------- /practicum/4/Week04-EnumsAndOperatorOveloading/snippets/02-enums/bookType.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | enum class BookType 4 | { 5 | UNKNOWN, 6 | CLASSICS, 7 | FANTASY, 8 | CRIMINAL, 9 | HORROR, 10 | ROMANCE, 11 | SCIENCE_FICTION 12 | }; -------------------------------------------------------------------------------- /practicum/7/Additional-02/Suitcase/Person.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | struct Person { 3 | String name; 4 | String address; 5 | String phone; 6 | 7 | Person(String name, String address, String phone) 8 | :name(name), address(address), phone(phone) {} 9 | }; 10 | -------------------------------------------------------------------------------- /practicum/3/10 - 13.05.2022/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "Axe.h" 4 | #include "Japanka.h" 5 | 6 | int main() { 7 | Weapon *asd = new Japanka(12, 23, "penka", 12); 8 | asd->attack("ivancho"); 9 | delete asd; 10 | return 0; 11 | } -------------------------------------------------------------------------------- /practicum/4/Week12-MultiInheritance/lab/solution/Student.cpp: -------------------------------------------------------------------------------- 1 | #include "Student.h" 2 | 3 | Student::Student(std::string_view name, const int number) 4 | : Person(name), m_number(number) { 5 | } 6 | 7 | const int Student::getNumber() const { 8 | return m_number; 9 | } 10 | -------------------------------------------------------------------------------- /exercises/2/week_2_IntroductionToClasses/Wallet.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class Wallet { 4 | private: 5 | double money; 6 | char username[32]; 7 | char password[16]; 8 | public: 9 | void witdraw(double amount); 10 | void initMoney() { 11 | money = 500; 12 | } 13 | }; -------------------------------------------------------------------------------- /practicum/4/Week06-FriendFunctionsAndGitHub/snippets/02-operatorsInAndOut/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "money.h" 3 | 4 | int main() 5 | { 6 | Money money; 7 | 8 | std::cin >> money; 9 | 10 | std::cout << money << std::endl; 11 | 12 | return 0; 13 | } -------------------------------------------------------------------------------- /practicum/4/Week12-MultiInheritance/lab/solution/Teacher.cpp: -------------------------------------------------------------------------------- 1 | #include "Teacher.h" 2 | 3 | Teacher::Teacher(std::string_view name, const double salary) 4 | : Person(name), m_salary(salary) { 5 | } 6 | 7 | const double Teacher::getSalary() const { 8 | return m_salary; 9 | } 10 | -------------------------------------------------------------------------------- /practicum/4/Week14-UnitTests/snippets/02-MultipleTestFiles/testsA.cpp: -------------------------------------------------------------------------------- 1 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 2 | #include "../doctest.h" 3 | #include "classA.h" 4 | 5 | TEST_CASE("test class A") 6 | { 7 | A a; 8 | 9 | REQUIRE(a.f() == 5); 10 | REQUIRE(a.g() == 'P'); 11 | } -------------------------------------------------------------------------------- /practicum/4/Week14-UnitTests/snippets/02-MultipleTestFiles/testsB.cpp: -------------------------------------------------------------------------------- 1 | //#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 2 | #include "../doctest.h" 3 | #include "classB.h" 4 | 5 | TEST_CASE("test class B") 6 | { 7 | B b; 8 | 9 | REQUIRE(b.f() == 7); 10 | REQUIRE(b.g() == 'L'); 11 | } -------------------------------------------------------------------------------- /practicum/4/Week09-StaticAndTemplates/lab/solutions/consultantUtils.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "computer.h" 4 | 5 | class ConsultantUtils 6 | { 7 | public: 8 | static bool isGoodForGaming(const Computer& computer); 9 | static bool isGoodForTravel(const Computer& computer); 10 | }; -------------------------------------------------------------------------------- /practicum/4/Week11-AbstractClassesAndPolymorphism/lab/solution/Utility.h: -------------------------------------------------------------------------------- 1 | #ifndef UTILITY_H 2 | #define UTILITY_H 3 | 4 | #include 5 | #include 6 | 7 | class Utility { 8 | public: 9 | static std::string toLowerStr(std::string str); 10 | }; 11 | 12 | #endif // !UTILITY_H 13 | -------------------------------------------------------------------------------- /practicum/4/Week11-AbstractClassesAndPolymorphism/lab/solution/Utility.cpp: -------------------------------------------------------------------------------- 1 | #include "Utility.h" 2 | 3 | std::string Utility::toLowerStr(std::string str) { 4 | for (std::string::iterator charIt = str.begin(); charIt != str.end(); charIt++) 5 | *charIt = std::tolower(*charIt); 6 | 7 | return str; 8 | } 9 | -------------------------------------------------------------------------------- /exercises/2/week_2_IntroductionToClasses/Source.cpp: -------------------------------------------------------------------------------- 1 | #include "Rational.h" 2 | #include "Wallet.h" 3 | 4 | int main() { 5 | 6 | Rational r; 7 | 8 | //Wallet w; 9 | //w.initMoney(); 10 | //w.witdraw(600); 11 | 12 | 13 | r.read(); 14 | r.print(); 15 | 16 | 17 | 18 | return 0; 19 | } -------------------------------------------------------------------------------- /exercises/4/week04/dummy.cpp: -------------------------------------------------------------------------------- 1 | #define N jdhfkjfdksj 2 | #define maxMacros(a,b) (a)>(b) ? a : b 3 | int main () { 4 | #ifdef test 5 | int debugMode = true; 6 | #endif 7 | int m = N; 8 | int p = N; 9 | int c = maxMacros(m,p); 10 | return 0; 11 | } 12 | 13 | // g++ -E .\dummy.cpp -D test=true -o dummy1.cpp -------------------------------------------------------------------------------- /exercises/1/exercises/07-files/students2.bin: -------------------------------------------------------------------------------- 1 | georgijorogo6oteodorasparuh -------------------------------------------------------------------------------- /lectures/1/streams/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0.0) 2 | project(streams VERSION 0.1.0) 3 | 4 | include(CTest) 5 | enable_testing() 6 | 7 | add_executable(streams main.cpp) 8 | 9 | set(CPACK_PROJECT_NAME ${PROJECT_NAME}) 10 | set(CPACK_PROJECT_VERSION ${PROJECT_VERSION}) 11 | include(CPack) 12 | -------------------------------------------------------------------------------- /lectures/1/struct/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0.0) 2 | project(struct VERSION 0.1.0) 3 | 4 | include(CTest) 5 | enable_testing() 6 | 7 | add_executable(struct main.cpp) 8 | 9 | set(CPACK_PROJECT_NAME ${PROJECT_NAME}) 10 | set(CPACK_PROJECT_VERSION ${PROJECT_VERSION}) 11 | include(CPack) 12 | -------------------------------------------------------------------------------- /exercises/2/week_2_IntroductionToClasses/Rational.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class Rational { 4 | private: 5 | int num; 6 | int dem; 7 | public: 8 | void print() const; 9 | void setNum(int _num); 10 | void setDem(int dem); 11 | int getNum() const; 12 | int getDem() const; 13 | void read(); 14 | 15 | }; -------------------------------------------------------------------------------- /lectures/1/files/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0.0) 2 | project(files VERSION 0.1.0) 3 | 4 | include(CTest) 5 | enable_testing() 6 | 7 | add_executable(files main.cpp product.cpp) 8 | 9 | set(CPACK_PROJECT_NAME ${PROJECT_NAME}) 10 | set(CPACK_PROJECT_VERSION ${PROJECT_VERSION}) 11 | include(CPack) 12 | -------------------------------------------------------------------------------- /exercises/2/week_11_Inheritance_sample_project/sampleProject/Students.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "DynamicArray.h" 3 | #include "Student.h" 4 | 5 | 6 | class Students { 7 | private: 8 | DynamicArray students; 9 | public: 10 | void add(const Student& st); 11 | void dosthOnlyForStudents() const; 12 | }; -------------------------------------------------------------------------------- /lectures/1/geometry/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0.0) 2 | project(geometry VERSION 0.1.0) 3 | 4 | include(CTest) 5 | enable_testing() 6 | 7 | add_executable(geometry main.cpp point3d.cpp) 8 | 9 | set(CPACK_PROJECT_NAME ${PROJECT_NAME}) 10 | set(CPACK_PROJECT_VERSION ${PROJECT_VERSION}) 11 | include(CPack) 12 | -------------------------------------------------------------------------------- /lectures/1/rational/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0.0) 2 | project(rational VERSION 0.1.0) 3 | 4 | include(CTest) 5 | enable_testing() 6 | 7 | add_executable(rational main.cpp rational.cpp) 8 | 9 | set(CPACK_PROJECT_NAME ${PROJECT_NAME}) 10 | set(CPACK_PROJECT_VERSION ${PROJECT_VERSION}) 11 | include(CPack) 12 | -------------------------------------------------------------------------------- /practicum/7/Week-10-Inheritance/Solutions/Task3/FuelTank.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "insufficent_fuel.h" 3 | class FuelTank 4 | { 5 | double capacity; 6 | double currLevel; 7 | public: 8 | FuelTank(double cap) : capacity(cap), currLevel(cap) 9 | {} 10 | void use(double toUse); 11 | void fill(double toRefill); 12 | }; 13 | 14 | -------------------------------------------------------------------------------- /practicum/7/Week-10-Inheritance/Solutions/Task3/Engine.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "CarPart.h" 3 | class Engine : public CarPart 4 | { 5 | unsigned short horsePower; 6 | friend std::ostream& operator<<(std::ostream& os, const Engine& obj); 7 | public: 8 | Engine(const char* manu, const char* desc, unsigned short hp = 0); 9 | }; 10 | 11 | -------------------------------------------------------------------------------- /exercises/2/week_2_IntroductionToClasses/Wallet.cpp: -------------------------------------------------------------------------------- 1 | #include "Wallet.h" 2 | #include 3 | 4 | void Wallet::witdraw(double amount) 5 | { 6 | if (amount > money) 7 | { 8 | std::cout << "Not enough money in your bank account\n"; 9 | return; 10 | } 11 | money -= amount; 12 | std::cout << "Widraw success"; 13 | } 14 | -------------------------------------------------------------------------------- /lectures/1/templates/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0.0) 2 | project(templates VERSION 0.1.0) 3 | 4 | include(CTest) 5 | enable_testing() 6 | 7 | add_executable(templates main.cpp ../files/product.cpp) 8 | 9 | set(CPACK_PROJECT_NAME ${PROJECT_NAME}) 10 | set(CPACK_PROJECT_VERSION ${PROJECT_VERSION}) 11 | include(CPack) 12 | -------------------------------------------------------------------------------- /practicum/2/11-polymorphism/solutions/MathFormulas.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "Point2D.hpp" 4 | 5 | class Formulas 6 | { 7 | public: 8 | static double getDistance2D(Point2D a, Point2D b) 9 | { 10 | double result = sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)); 11 | return result; 12 | } 13 | }; 14 | -------------------------------------------------------------------------------- /exercises/4/week01/README.md: -------------------------------------------------------------------------------- 1 | # Topics 2 | 3 | ## Malloc vs new 4 | ### What is actually new/delete 5 | ## T* vs T*& 6 | ## How to generate a dynamic matrix 7 | 8 | ## Tasks 9 | ### Generate all Combinations with sum equal with integers between 0 and N 10 | ### Generate all Combinations with sum/subtraction equal with integers between 0 and N 11 | -------------------------------------------------------------------------------- /practicum/4/Week05-MoreOperatorOverloading/snippets/01-operatorPlus/main.cpp: -------------------------------------------------------------------------------- 1 | #include "money.h" 2 | 3 | int main() 4 | { 5 | Money money1(2, 60), money2(3, 50); 6 | 7 | money1.print(); 8 | money1 += money2; 9 | money1.print(); 10 | 11 | Money money3 = money1 + money2; 12 | money3.print(); 13 | 14 | return 0; 15 | } -------------------------------------------------------------------------------- /practicum/7/Week-05-Big-four/Classwork/source.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(){ 6 | std::string str; 7 | str = "Hello world"; 8 | std::cout << str << '\n'; 9 | 10 | str.push_back('!'); 11 | std::cout << str; 12 | str.pop_back(); 13 | std::cout << str; 14 | } 15 | 16 | -------------------------------------------------------------------------------- /practicum/4/Week12-MultiInheritance/lab/solution/Assistant.h: -------------------------------------------------------------------------------- 1 | #ifndef ASSISTANT_H 2 | #define ASSISTANT_H 3 | 4 | #include "Student.h" 5 | #include "Teacher.h" 6 | 7 | class Assistant : public Student, public Teacher { 8 | public: 9 | Assistant(std::string_view name, const int number, const double salary); 10 | }; 11 | 12 | #endif // !ASSISTANT_H 13 | -------------------------------------------------------------------------------- /exercises/2/week_6_friendFuncAndString/Source.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "String.h" 3 | 4 | int main() { 5 | String str("If"), str2(" Antonov"); 6 | 7 | str.add(" Antonov"); 8 | 9 | //String result = str + str2; 10 | 11 | std::cout << "fsgvadv"; 12 | std::cout << str; 13 | std::cout << "fsgvadv"; 14 | 15 | return 0; 16 | } -------------------------------------------------------------------------------- /lectures/1/highorder/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0.0) 2 | project(highorder VERSION 0.1.0) 3 | 4 | include(CTest) 5 | enable_testing() 6 | 7 | set (CMAKE_CXX_STANDARD 20) 8 | 9 | add_executable(highorder main.cpp) 10 | 11 | set(CPACK_PROJECT_NAME ${PROJECT_NAME}) 12 | set(CPACK_PROJECT_VERSION ${PROJECT_VERSION}) 13 | include(CPack) 14 | -------------------------------------------------------------------------------- /practicum/4/Week05-MoreOperatorOverloading/snippets/02-operatorMinus/main.cpp: -------------------------------------------------------------------------------- 1 | #include "money.h" 2 | 3 | int main() 4 | { 5 | Money money1(2, 60), money2(3, 50); 6 | 7 | money2.print(); 8 | money2 -= money1; 9 | money2.print(); 10 | 11 | Money money3 = Money(2, 80) - Money(1, 10); 12 | money3.print(); 13 | 14 | return 0; 15 | } -------------------------------------------------------------------------------- /practicum/4/Week14-UnitTests/snippets/01-OurFirstUniTests/calculator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class Calculator 4 | { 5 | public: 6 | double sum(double first, double second); 7 | 8 | double diff(double first, double second); 9 | 10 | double divide(double first, double second); 11 | 12 | double multiply(double first, double second); 13 | }; -------------------------------------------------------------------------------- /exercises/2/week_11_Inheritance_sample_project/sampleProject/Student.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | class Student { 5 | private: 6 | std::string name; 7 | int facultyNumber; 8 | 9 | public: 10 | const char* getName() const { 11 | return ""; 12 | } 13 | void sthSpecificForStudent() const { 14 | std::cout << " "; 15 | } 16 | }; -------------------------------------------------------------------------------- /lectures/1/stack/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0.0) 2 | project(stack VERSION 0.1.0) 3 | 4 | include(CTest) 5 | enable_testing() 6 | 7 | add_executable(stack main.cpp stack.cpp rstack.cpp) 8 | include_directories(../common) 9 | 10 | set(CPACK_PROJECT_NAME ${PROJECT_NAME}) 11 | set(CPACK_PROJECT_VERSION ${PROJECT_VERSION}) 12 | include(CPack) 13 | -------------------------------------------------------------------------------- /exercises/2/week_4_taskWithWebServers/WebServer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | struct WebServer { 5 | char URL[501]; 6 | int IPv4Address[4]; 7 | char OS[21]; 8 | bool operator <(const WebServer& other); 9 | bool operator ==(const WebServer& other); 10 | bool operator !=(const WebServer& other); 11 | void print() const; 12 | void read(); 13 | 14 | }; -------------------------------------------------------------------------------- /lectures/1/player/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0.0) 2 | project(player VERSION 0.1.0) 3 | 4 | include(CTest) 5 | enable_testing() 6 | 7 | add_executable(player main.cpp player.cpp hero.cpp superhero.cpp ai.cpp bot.cpp boss.cpp) 8 | 9 | set(CPACK_PROJECT_NAME ${PROJECT_NAME}) 10 | set(CPACK_PROJECT_VERSION ${PROJECT_VERSION}) 11 | include(CPack) 12 | -------------------------------------------------------------------------------- /practicum/4/Week12-MultiInheritance/lab/solution/Student.h: -------------------------------------------------------------------------------- 1 | #ifndef STUDENT_H 2 | #define STUDENT_H 3 | 4 | #include "Person.h" 5 | 6 | class Student : virtual public Person { 7 | public: 8 | Student(std::string_view name, const int number); 9 | 10 | const int getNumber() const; 11 | 12 | protected: 13 | int m_number; 14 | }; 15 | 16 | #endif // !STUDENT_H 17 | -------------------------------------------------------------------------------- /practicum/7/Week-10-Inheritance/Solutions/Task3/Engine.cpp: -------------------------------------------------------------------------------- 1 | #include "Engine.h" 2 | 3 | Engine::Engine(const char* manu, const char* desc, unsigned short hp) 4 | : CarPart(manu, desc), horsePower(hp) 5 | { 6 | } 7 | 8 | std::ostream& operator<<(std::ostream& os, const Engine& obj) 9 | { 10 | os << (const CarPart&)obj; 11 | os << obj.horsePower << '\n'; 12 | } 13 | -------------------------------------------------------------------------------- /practicum/4/Week12-MultiInheritance/lab/solution/Teacher.h: -------------------------------------------------------------------------------- 1 | #ifndef TEACHER_H 2 | #define TEACHER_H 3 | 4 | #include "Person.h" 5 | 6 | class Teacher : virtual public Person { 7 | public: 8 | Teacher(std::string_view name, const double salary); 9 | 10 | const double getSalary() const; 11 | 12 | protected: 13 | double m_salary; 14 | }; 15 | 16 | #endif // !TEACHER_H 17 | -------------------------------------------------------------------------------- /practicum/2/11-polymorphism/solutions/Triangle.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Shape.h" 3 | #include "Point2D.hpp" 4 | 5 | class Triangle : public Shape 6 | { 7 | public: 8 | Triangle(Point2D _a, Point2D _b, Point2D _c); 9 | 10 | public: 11 | double getPerimeter() const override; 12 | Shape* clone(); 13 | private: 14 | Point2D a; 15 | Point2D b; 16 | Point2D c; 17 | }; 18 | -------------------------------------------------------------------------------- /practicum/4/Week12-MultiInheritance/lab/solution/Person.h: -------------------------------------------------------------------------------- 1 | #ifndef PERSON_H 2 | #define PERSON_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class Person { 9 | public: 10 | Person(std::string_view name); 11 | 12 | std::string_view getName() const; 13 | 14 | protected: 15 | std::string m_name; 16 | }; 17 | 18 | #endif // !PERSON_H 19 | -------------------------------------------------------------------------------- /practicum/3/10 - 13.05.2022/Axe.h: -------------------------------------------------------------------------------- 1 | #include "melee.h" 2 | 3 | class Axe : public Melee { 4 | public: 5 | Axe(); 6 | Axe(int speed, const char *name, double damage); 7 | Axe(const Axe &other); 8 | 9 | virtual ~Axe(); 10 | 11 | virtual void attack(const char *target); 12 | 13 | Axe &operator=(const Axe &other); 14 | virtual Weapon *clone() const; 15 | }; -------------------------------------------------------------------------------- /practicum/7/Week-1/Solutions/Task-2/Gradebook.h: -------------------------------------------------------------------------------- 1 | const int maxSubjectsCount = 100; 2 | const int subjectNameMaxLen = 30; 3 | const int subjectMaxGrades = 15; 4 | 5 | struct Subject{ 6 | int gradeIndex = 0; 7 | int grades[subjectMaxGrades]; 8 | char name[subjectNameMaxLen]; 9 | }; 10 | 11 | struct Gradebook 12 | { 13 | Subject subjects[maxSubjectsCount]; 14 | }; 15 | -------------------------------------------------------------------------------- /practicum/7/Additional-01/Classwork/Task-3/main.cpp: -------------------------------------------------------------------------------- 1 | #include "Book.h" 2 | 3 | int main(){ 4 | Book b("Hello", "World", 1940, 10); 5 | std::ofstream os("file.dat", std::ios::binary); 6 | os << b; 7 | os.close(); 8 | Book c("Test", "Test", 22,12); 9 | std::ifstream is("file.dat", std::ios::binary); 10 | is >> c; 11 | c.printBook(); 12 | is.close(); 13 | } -------------------------------------------------------------------------------- /practicum/7/Week-10-Inheritance/Solutions/Task1/Animal.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | class Animal { 3 | public: 4 | Animal(); 5 | Animal(const char* name, unsigned age); 6 | Animal(const Animal& other); 7 | Animal& operator=(const Animal& other); 8 | ~Animal(); 9 | 10 | 11 | void print() const; 12 | void setName(const char* name); 13 | 14 | private: 15 | char* name; 16 | unsigned age; 17 | }; -------------------------------------------------------------------------------- /exercises/2/week_11_Inheritance_sample_project/sampleProject/Program.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Students.h" 3 | #include "DBManager.h" 4 | 5 | class Program { 6 | private: 7 | Students students; 8 | 9 | public: 10 | void start() 11 | { 12 | DBManager::readStudentsInfoFromDB(students); 13 | } 14 | void executeAdd() { 15 | Student st; 16 | students.add(st); 17 | } 18 | }; -------------------------------------------------------------------------------- /practicum/2/11-polymorphism/solutions/Circle.cpp: -------------------------------------------------------------------------------- 1 | #define _USE_MATH_DEFINES 2 | #include 3 | #include "Circle.h" 4 | 5 | Circle::Circle(Point2D c, double r) : center(c), radius(r) {} 6 | 7 | double Circle::getPerimeter() const 8 | { 9 | double perimeter = 2 * M_PI * radius; 10 | return perimeter; 11 | } 12 | 13 | Shape* Circle::clone() 14 | { 15 | return new Circle(*this); 16 | } 17 | -------------------------------------------------------------------------------- /practicum/2/11-polymorphism/solutions/Circle.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Shape.h" 3 | #include "Point2D.hpp" 4 | 5 | class Circle : public Shape 6 | { 7 | public: 8 | Circle(Point2D c, double r); 9 | 10 | public: 11 | double getPerimeter() const override; 12 | double getArea() const override; 13 | 14 | Shape* clone(); 15 | 16 | private: 17 | Point2D center; 18 | double radius; 19 | }; 20 | -------------------------------------------------------------------------------- /practicum/4/Week06-FriendFunctionsAndGitHub/snippets/01-moreArithmeticOperators/main.cpp: -------------------------------------------------------------------------------- 1 | #include "money.h" 2 | #include 3 | 4 | int main() 5 | { 6 | Money money1(2, 60); 7 | 8 | Money money2 = money1 + 3; 9 | money2.print(); 10 | 11 | Money money3 = 5 + money1; 12 | money3.print(); 13 | 14 | int a; 15 | 16 | std::cin >> a; 17 | 18 | return 0; 19 | } -------------------------------------------------------------------------------- /exercises/2/PolimorphismAndAbstract/Garage.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Cars.h" 3 | 4 | class Garage { 5 | private: 6 | Car** cars; 7 | int size; 8 | int capacity; 9 | void copy(const Garage& other); 10 | void destroy(); 11 | public: 12 | Garage(); 13 | Garage(const Garage& other); 14 | Garage& operator =(const Garage& other); 15 | ~Garage(); 16 | void add(Car* addedCar); 17 | }; -------------------------------------------------------------------------------- /practicum/2/11-polymorphism/solutions/Rectangle.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Shape.h" 3 | #include "Point2D.hpp" 4 | 5 | class Rectangle : public Shape 6 | { 7 | public: 8 | Rectangle(Point2D bottom, Point2D upper); 9 | 10 | public: 11 | virtual double getPerimeter() const override; 12 | virtual Shape* clone() override; 13 | 14 | private: 15 | Point2D bottomLeft; 16 | Point2D upperRight; 17 | }; 18 | -------------------------------------------------------------------------------- /practicum/7/Additional-02/Suitcase/Suit.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ClothingItem.h" 3 | 4 | class Suit : public ClothingItem { 5 | public: 6 | Suit(const String& color, const String& size, size_t price) 7 | :ClothingItem(color, size, price) {} 8 | 9 | virtual Type getType() const { 10 | return Type::SUIT; 11 | } 12 | 13 | virtual ClothingItem* clone() { 14 | return new Suit(*this); 15 | } 16 | }; -------------------------------------------------------------------------------- /exercises/2/week_4_taskWithWebServers/Source.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "ServerFarm.h" 3 | #include "WebServer.h"; 4 | 5 | int main() { 6 | WebServer server, server2; 7 | server.read(); 8 | server2.read(); 9 | server.print(); 10 | server2.print(); 11 | std::cout << (server < server2); 12 | std::cout << (server == server2); 13 | 14 | ServerFarm farm; 15 | 16 | return 0; 17 | } -------------------------------------------------------------------------------- /practicum/4/Week12-MultiInheritance/lab/solution/Main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "Assistant.h" 4 | 5 | int main() { 6 | Assistant* svilen = new Assistant("Svilen Andonov", 43665, 400); 7 | 8 | std::cout << svilen->getName() << std::endl; 9 | std::cout << svilen->getNumber() << std::endl; 10 | std::cout << svilen->getSalary() << std::endl; 11 | 12 | delete svilen; 13 | 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /practicum/4/Week14-UnitTests/snippets/04-TDD/factorielSolver.cpp: -------------------------------------------------------------------------------- 1 | #include "factorielSolver.h" 2 | #include 3 | 4 | long long FactorielSolver::solve(long long n) 5 | { 6 | if (n < 0) 7 | { 8 | throw std::invalid_argument("not defined for negative numbers"); 9 | } 10 | 11 | if (n == 0 || n == 1) 12 | { 13 | return 1; 14 | } 15 | 16 | return n * solve(n - 1); 17 | } -------------------------------------------------------------------------------- /practicum/4/Week06-FriendFunctionsAndGitHub/snippets/02-operatorsInAndOut/money.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class Money 6 | { 7 | private: 8 | unsigned int levs; 9 | unsigned int stotinkas; 10 | 11 | public: 12 | Money(); 13 | 14 | friend std::istream& operator >> (std::istream& in, Money& money); 15 | friend std::ostream& operator << (std::ostream& out, const Money& money); 16 | }; -------------------------------------------------------------------------------- /practicum/7/Week-10-Inheritance/Solutions/Task3/insufficent_fuel.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | class insufficent_fuel : public std::logic_error 5 | { 6 | public: 7 | insufficent_fuel(const char* msg) : std::logic_error(msg) 8 | {} 9 | }; 10 | 11 | int main() 12 | { 13 | try { 14 | //... 15 | } 16 | catch (insufficent_fuel& e) { 17 | std::cerr << e.what(); 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /lectures/1/player/printable.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __PRINTABLE_HPP 2 | #define __PRINTABLE_HPP 3 | 4 | #include 5 | 6 | class Printable { 7 | public: 8 | virtual void print(std::ostream& os = std::cout) const = 0; 9 | virtual Printable* clone() const = 0; 10 | virtual ~Printable() {} 11 | 12 | void println(std::ostream& os = std::cout) const { 13 | print(os); 14 | os << std::endl; 15 | } 16 | }; 17 | 18 | #endif -------------------------------------------------------------------------------- /practicum/3/10 - 13.05.2022/melee.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Weapon.h" 4 | 5 | class Melee : public virtual Weapon { 6 | private: 7 | int speed; 8 | 9 | public: 10 | Melee(); 11 | Melee(int speed, char const *name, double damage); 12 | Melee(const Melee &other); 13 | 14 | virtual ~Melee(); 15 | 16 | int getSpeed() const; 17 | virtual void hit(); 18 | 19 | Melee &operator=(const Melee &other); 20 | }; -------------------------------------------------------------------------------- /practicum/7/Week-10-Inheritance/Solutions/Task3/FuelTank.cpp: -------------------------------------------------------------------------------- 1 | #include "FuelTank.h" 2 | 3 | void FuelTank::use(double toUse) 4 | { 5 | if (toUse > currLevel) { 6 | throw insufficent_fuel("Too much fuel used"); 7 | } 8 | currLevel -= toUse; 9 | } 10 | 11 | void FuelTank::fill(double toRefill) 12 | { 13 | if (currLevel + toRefill > capacity) { 14 | currLevel = capacity; 15 | } 16 | else { 17 | currLevel += toRefill; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /practicum/4/Week04-EnumsAndOperatorOveloading/snippets/03-operatorOverloading/money.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class Money 4 | { 5 | private: 6 | unsigned int levs; 7 | unsigned int stotinkas; 8 | 9 | public: 10 | Money(const unsigned int levs, const unsigned int stotinkas); 11 | 12 | bool operator == (const Money& other) const; 13 | bool operator != (const Money& other) const; 14 | bool operator < (const Money& other) const; 15 | }; -------------------------------------------------------------------------------- /exercises/2/week_3_big4/Polynome.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | class Polynome { 5 | private: 6 | int* coef; 7 | int degree; 8 | void copy(const Polynome& other); 9 | void destroy(); 10 | public: 11 | Polynome(); 12 | Polynome(int degree); 13 | Polynome(const Polynome& other); 14 | Polynome& operator=(const Polynome& other); 15 | Polynome& operator *(int scalar); 16 | 17 | ~Polynome(); 18 | 19 | void print() const; 20 | 21 | }; -------------------------------------------------------------------------------- /practicum/3/10 - 13.05.2022/Ranged.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Weapon.h" 4 | 5 | class Ranged : public virtual Weapon { 6 | private: 7 | int range; 8 | 9 | public: 10 | Ranged(); 11 | Ranged(int range, char const *name, double damage); 12 | Ranged(const Ranged &other); 13 | 14 | virtual ~Ranged(); 15 | 16 | int getRanged() const; 17 | virtual void shoot(); 18 | 19 | Ranged &operator=(const Ranged &other); 20 | }; -------------------------------------------------------------------------------- /practicum/4/Week04-EnumsAndOperatorOveloading/snippets/01-separateCompilation/book.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | const std::size_t MAX_BOOK_NAME_SIZE = 100; 6 | 7 | class Book 8 | { 9 | private: 10 | char name[MAX_BOOK_NAME_SIZE]; 11 | int yearOfPublication; 12 | 13 | public: 14 | Book(); 15 | Book(const char* name, const int yearOfPublication); 16 | 17 | const char* getName(); 18 | 19 | void print(); 20 | }; -------------------------------------------------------------------------------- /practicum/4/Week07-Files/snippets/01-writingToTextFile/money.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class Money 6 | { 7 | private: 8 | unsigned int levs; 9 | unsigned int stotinkas; 10 | 11 | public: 12 | Money(unsigned int levs = 0, unsigned int stotinkas = 0); 13 | 14 | friend std::istream& operator >> (std::istream& in, Money& money); 15 | friend std::ostream& operator << (std::ostream& out, const Money& money); 16 | }; -------------------------------------------------------------------------------- /practicum/7/Week-10-Inheritance/Solutions/Task1/Pet.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Animal.h" 3 | class Pet :public Animal { 4 | public: 5 | Pet(); 6 | Pet(const char* name, unsigned age, const char* owner, unsigned phone); 7 | Pet(const Pet& other); 8 | Pet& operator=(const Pet& other); 9 | ~Pet(); 10 | 11 | void print() const; 12 | void changeOwner(const char* name, unsigned phone); 13 | 14 | private: 15 | char* owner; 16 | unsigned phone; 17 | }; -------------------------------------------------------------------------------- /practicum/7/Week-07-Streams-Files/Task-1/Source.cpp: -------------------------------------------------------------------------------- 1 | #include "Animal.h" 2 | #include 3 | 4 | int main() { 5 | 6 | Animal a("Pesho", "Kon", 12); 7 | Animal b("Gosho Petrov", "Ovca Golqma", 3); 8 | 9 | a.writeToTextFile("Jivotinki.txt"); 10 | //b.writeToTextFile("Jivotinki.txt"); 11 | 12 | a.serialize("animals.dat"); 13 | 14 | std::cout << "Enter name, breed and age: \n"; 15 | std::cin >> b; 16 | std::cout << b; 17 | 18 | return 0; 19 | } -------------------------------------------------------------------------------- /exercises/1/exercises/07-files/merged.bin: -------------------------------------------------------------------------------- 1 | pe6ogeorgiivanjoromariago6oteodorasparuh -------------------------------------------------------------------------------- /practicum/2/11-polymorphism/solutions/Shape.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class Shape 6 | { 7 | public: 8 | virtual void print() const = 0; 9 | virtual void readFromFile( std::ifstream& stream ) = 0; 10 | virtual bool isInside( double, double ) const = 0; 11 | virtual const Shape* getShapeAt( size_t ) const = 0; 12 | 13 | virtual double getPerimeter() const = 0; 14 | virtual double getArea() const = 0; 15 | virtual Shape* clone() = 0; 16 | }; 17 | -------------------------------------------------------------------------------- /practicum/4/Week07-Files/snippets/02-readingFromTextFile/dadJokes.txt: -------------------------------------------------------------------------------- 1 | "I'm afraid for the calendar. Its days are numbered." 2 | "My wife said I should do lunges to stay in shape. That would be a big step forward." 3 | "Why do fathers take an extra pair of socks when they go golfing?" "In case they get a hole in one!" 4 | "Singing in the shower is fun until you get soap in your mouth. Then it's a soap opera." 5 | "What do a tick and the Eiffel Tower have in common?" "They're both Paris sites." -------------------------------------------------------------------------------- /practicum/7/Week-03-Classes/2-Waffles/Source.cpp: -------------------------------------------------------------------------------- 1 | #include "WaffleShop.h" 2 | 3 | int main() { 4 | 5 | WaffleShop fmi(10); 6 | 7 | fmi.orderWaffles(BOYKO, 3); 8 | fmi.printInventory(); 9 | 10 | fmi.sellWaffle(); 11 | 12 | fmi.orderWaffles(BOROVETS, 10); 13 | fmi.printInventory(); 14 | 15 | fmi.sellWaffle(); 16 | fmi.sellWaffle(); 17 | fmi.sellWaffle(); 18 | 19 | fmi.printInventory(); 20 | std::cout << fmi.getIncome() << std::endl; 21 | 22 | 23 | return 0; 24 | } -------------------------------------------------------------------------------- /practicum/3/14 - 03.06.2022/Dish.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | class Dish { 6 | protected: 7 | char *ingredients[128]; 8 | int time; 9 | int numberOfIngredients; 10 | 11 | public: 12 | Dish(); 13 | Dish(const char **ingredients, int time, int numberOfIngredients); 14 | Dish(const Dish &other); 15 | Dish &operator=(const Dish &other); 16 | 17 | virtual ~Dish(); 18 | 19 | virtual void print() const; 20 | }; -------------------------------------------------------------------------------- /practicum/4/Week06-FriendFunctionsAndGitHub/lab/solutions/Task01/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Time.h" 3 | 4 | int main () 5 | { 6 | Time t1(2, 40), t2(3, 30), t3, t4, t5; 7 | 8 | std::cout << (t1 + t2); 9 | 10 | t3 = t1 + t2; 11 | std::cout << t3; 12 | 13 | t4 = t1 + 5; 14 | std::cout << t4; 15 | 16 | t5 = 6 + t1; 17 | std::cout << t5; 18 | 19 | std::cout << std::boolalpha << (t1 > t2) << std::endl; 20 | 21 | return 0; 22 | } -------------------------------------------------------------------------------- /practicum/7/Week-03-Classes/1-Scientists/Source.cpp: -------------------------------------------------------------------------------- 1 | #include "University.h" 2 | 3 | int main() { 4 | 5 | University su(10); 6 | 7 | su.hire("Bosa Na Kokosa", ASSOC_PROF, 1000, 100); 8 | su.hire("Tupcho Neumnikov", ASSOC_PROF, 5000, 80); 9 | su.hire("Nadi", ASSISTANT, 200, 0); 10 | su.hire("Shefa Shefa", PROF, 55555, 90); 11 | 12 | su.print(); 13 | 14 | su.fire("Tupcho"); //Nothing will hapen 15 | su.fire("Tupcho Neumnikov"); 16 | 17 | su.print(); 18 | 19 | return 0; 20 | } -------------------------------------------------------------------------------- /practicum/3/10 - 13.05.2022/Japanka.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Ranged.h" 4 | #include "melee.h" 5 | 6 | class Japanka : public Melee, public Ranged { 7 | public: 8 | Japanka(); 9 | Japanka(int speed, int range, const char *name, double damage); 10 | Japanka(const Japanka &other); 11 | 12 | virtual ~Japanka(); 13 | 14 | virtual void attack(const char *target); 15 | 16 | Japanka &operator=(const Japanka &other); 17 | 18 | virtual Weapon *clone() const; 19 | }; -------------------------------------------------------------------------------- /practicum/3/13 - 27.05.2022/JSONString.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "JSONEntry.hpp" 3 | #include 4 | 5 | class JSONString : public JSONEntry { 6 | public: 7 | std::string value; 8 | JSONString(const char *value); 9 | virtual void print(std::ostream &); 10 | virtual ~JSONString() {} 11 | }; 12 | 13 | inline JSONString::JSONString(const char *value) { 14 | this->value = value; 15 | } 16 | 17 | void JSONString::print(std::ostream &os) { 18 | os << value; 19 | } -------------------------------------------------------------------------------- /practicum/4/Week09-StaticAndTemplates/snippets/06-multipleTemplateArguments.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | template // by default, the second argument will be 'int' 5 | struct MyPair 6 | { 7 | T first; 8 | U second; 9 | }; 10 | 11 | int main () 12 | { 13 | MyPair pair1 = {99, "Kireto"}; 14 | MyPair pair2 = {"Pesho", 'P'}; 15 | MyPair pair3 = {3.14, 3}; 16 | 17 | return 0; 18 | } -------------------------------------------------------------------------------- /practicum/4/Week10-Inheritance/lab/solution/Food.h: -------------------------------------------------------------------------------- 1 | #ifndef FOOD_H 2 | #define FOOD_H 3 | 4 | #include "MenuItem.h" 5 | 6 | class Food : public MenuItem { 7 | public: 8 | Food(std::string_view name, const int quantity, std::string_view description, const double price, const bool isBig, const bool isVegan); 9 | 10 | std::string getInfo() const override; 11 | 12 | MenuItem* clone() const override; 13 | 14 | private: 15 | bool isBig; 16 | bool isVegan; 17 | }; 18 | 19 | #endif // !FOOD_H 20 | -------------------------------------------------------------------------------- /exercises/1/exercises/08 - templates/problems.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | template 4 | It find(It first, It last, T value) 5 | { 6 | for (; first != last; ++first) 7 | { 8 | if (*first == value) 9 | { 10 | return first; 11 | } 12 | } 13 | 14 | return first; 15 | } 16 | 17 | int main() 18 | { 19 | const int arr[3]{0, 2, 1}; 20 | 21 | std::cout << find(std::begin(arr), std::end(arr), 1) - std::begin(arr); 22 | 23 | return 0; 24 | } -------------------------------------------------------------------------------- /exercises/2/week_5_tasks/SumAvgCalculator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | class SumAvgCalculator { 5 | private: 6 | int totalSum; 7 | int size; 8 | public: 9 | SumAvgCalculator(int initialValue); 10 | int sum() const; 11 | void add(unsigned number); 12 | void sub(int number); 13 | int num() const { 14 | return size; 15 | } 16 | double avarage() const; 17 | SumAvgCalculator operator +(const SumAvgCalculator& other); 18 | SumAvgCalculator& operator +=(const SumAvgCalculator& other); 19 | }; -------------------------------------------------------------------------------- /practicum/3/13 - 27.05.2022/JSONNumber.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "JSONEntry.hpp" 3 | 4 | template 5 | class JSONNumber : public JSONEntry { 6 | public: 7 | JSONNumber(T num); 8 | T value; 9 | virtual void print(std::ostream &); 10 | virtual ~JSONNumber() {} 11 | }; 12 | 13 | template 14 | void JSONNumber::print(std::ostream &os) { 15 | os << value; 16 | } 17 | 18 | template 19 | JSONNumber::JSONNumber(T num) { 20 | this->value = num; 21 | } -------------------------------------------------------------------------------- /lectures/1/stack/abstract_stack.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __ABSTRACT_STACK 2 | #define __ABSTRACT_STACK 3 | 4 | template 5 | class AbstractStack { 6 | public: 7 | // проверка за празнота 8 | virtual bool empty() const = 0; 9 | 10 | // включване на елемент 11 | virtual void push(T const& x) = 0; 12 | 13 | // намиране на последния включен елемент 14 | virtual T const& peek() const = 0; 15 | 16 | // изключване на последния включен елемент 17 | virtual T pop() = 0; 18 | }; 19 | 20 | #endif -------------------------------------------------------------------------------- /practicum/3/14 - 03.06.2022/SurfNTurf.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "MeatDish.h" 3 | #include "SeafoodDish.h" 4 | 5 | class SurfNTurf : public MeatDish, public SeafoodDish { 6 | public: 7 | SurfNTurf(); 8 | SurfNTurf(const char **ingredients, 9 | int time, int numberOfIngredients, Meat meat, const char *fishName); 10 | SurfNTurf(SurfNTurf const &other); 11 | 12 | virtual ~SurfNTurf(); 13 | 14 | void print() const; 15 | 16 | SurfNTurf &operator=(SurfNTurf const &other); 17 | }; 18 | -------------------------------------------------------------------------------- /practicum/3/14 - 03.06.2022/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #pragma warning(disable : 4996) 3 | #include "SurfNTurf.h" 4 | 5 | int main() { 6 | char *asd[23]; 7 | asd[0] = new char[100]; 8 | asd[1] = new char[100]; 9 | strcpy(asd[0], "a"); 10 | strcpy(asd[1], "a"); 11 | try { 12 | SurfNTurf d((const char **)asd, 2, 2, Meat::Pork, "nemo"); 13 | d.print(); 14 | } catch (std::logic_error e) { 15 | std::cout << e.what() << std::endl; 16 | } 17 | 18 | return 0; 19 | } -------------------------------------------------------------------------------- /practicum/3/13 - 27.05.2022/JSONObj.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "JSONEntry.hpp" 3 | #include 4 | #include 5 | #include 6 | 7 | class JSONObj : public JSONEntry { 8 | public: 9 | std::map m; 10 | 11 | virtual void print(std::ostream &out) { 12 | for (const auto &n : m) { 13 | out << n.first << " : "; 14 | n.second->print(out); 15 | out << std::endl; 16 | } 17 | } 18 | virtual ~JSONObj() = default; 19 | }; -------------------------------------------------------------------------------- /practicum/4/Week04-EnumsAndOperatorOveloading/snippets/03-operatorOverloading/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "money.h" 3 | 4 | int main() 5 | { 6 | int a = 5, b = 6; 7 | 8 | if (a == b) 9 | { 10 | // ... 11 | } 12 | 13 | Money m1(2, 40), m2(2, 40), m3(3, 80); 14 | 15 | std::cout << std::boolalpha << (m1 == m2) << std::endl; 16 | std::cout << std::boolalpha << (m1 != m3) << std::endl; 17 | std::cout << std::boolalpha << (m1 < m3) << std::endl; 18 | 19 | return 0; 20 | } -------------------------------------------------------------------------------- /practicum/4/Week10-Inheritance/lab/solution/Drink.h: -------------------------------------------------------------------------------- 1 | #ifndef DRINK_H 2 | #define DRINK_H 3 | 4 | #include "MenuItem.h" 5 | #include "ServingType.h" 6 | 7 | class Drink : public MenuItem { 8 | public: 9 | Drink(std::string_view name, const int quantity, std::string_view description, const double price, const ServingType servingType); 10 | 11 | std::string getInfo() const override; 12 | 13 | MenuItem* clone() const override; 14 | 15 | protected: 16 | ServingType m_servingType; 17 | }; 18 | 19 | #endif // !DRINK_H 20 | -------------------------------------------------------------------------------- /practicum/3/14 - 03.06.2022/SeafoodDish.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Dish.h" 3 | class SeafoodDish : virtual public Dish { 4 | protected: 5 | char *fishName; 6 | 7 | public: 8 | SeafoodDish(); 9 | SeafoodDish(const char *fishName, const char **ingredients, 10 | int time, int numberOfIngredients); 11 | SeafoodDish(const SeafoodDish &other); 12 | 13 | virtual ~SeafoodDish(); 14 | 15 | virtual void print() const; 16 | 17 | SeafoodDish &operator=(const SeafoodDish &other); 18 | }; 19 | -------------------------------------------------------------------------------- /practicum/7/Week-02-Struct/Solutions/Task-2/Warrior.h: -------------------------------------------------------------------------------- 1 | 2 | enum Rank{ 3 | MAJOR, SERGEANT, OFFICER, OTHER 4 | }; 5 | 6 | enum Country{ 7 | BULGARIA, RUSSIA, UKRAINE, OTHER 8 | }; 9 | 10 | struct Warrior 11 | { 12 | Rank mRank; 13 | Country mCountry; 14 | short mHeight; 15 | short mAge; 16 | 17 | void printWarrior() const; 18 | }; 19 | 20 | 21 | void Warrior::printWarrior() const{ 22 | //cout the enums the way we know 23 | std::cout << mHeight << ' ' << mAge << '\n'; 24 | } 25 | 26 | 27 | -------------------------------------------------------------------------------- /practicum/4/Week07-Files/snippets/01-writingToTextFile/money.cpp: -------------------------------------------------------------------------------- 1 | #include "money.h" 2 | 3 | Money::Money(unsigned int levs, unsigned int stotinkas) 4 | : levs(levs), stotinkas(stotinkas) {} 5 | 6 | std::istream& operator >> (std::istream& in, Money& money) 7 | { 8 | in >> money.levs >> money.stotinkas; 9 | 10 | return in; 11 | } 12 | 13 | std::ostream& operator << (std::ostream& out, const Money& money) 14 | { 15 | out << money.levs << " levs and " << money.stotinkas << " stotinkas"; 16 | 17 | return out; 18 | } -------------------------------------------------------------------------------- /exercises/2/week_11_Inheritance_sample_project/sampleProject/DBManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "Students.h" 4 | 5 | class DBManager { 6 | 7 | public: 8 | static void readStudentsInfoFromDB(Students& students); 9 | static void save(); 10 | }; 11 | 12 | void DBManager::readStudentsInfoFromDB(Students& students) { 13 | 14 | std::cout << "Data was read successfully\n"; 15 | } 16 | 17 | void DBManager::save() 18 | { 19 | std::cout << "Successfully saved all the information\n"; 20 | } 21 | -------------------------------------------------------------------------------- /practicum/2/11-polymorphism/solutions/Rectangle.cpp: -------------------------------------------------------------------------------- 1 | #include "Rectangle.h" 2 | #include "MathFormulas.hpp" 3 | 4 | Rectangle::Rectangle(Point2D bottom, Point2D upper) :bottomLeft(bottom), upperRight(upper) {} 5 | 6 | double Rectangle::getPerimeter() const 7 | { 8 | double width = abs(upperRight.x - bottomLeft.x); 9 | double height = abs(upperRight.y - bottomLeft.y); 10 | 11 | double perimeter = 2 * (width + height); 12 | return perimeter; 13 | } 14 | 15 | Shape* Rectangle::clone() 16 | { 17 | return new Rectangle(*this); 18 | } 19 | -------------------------------------------------------------------------------- /practicum/4/Week07-Files/lab/solutions/task04.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main (int agrc, char** argv) 5 | { 6 | if (agrc == 2) 7 | { 8 | std::ifstream file(argv[1], std::ios::binary); 9 | 10 | if (!file.is_open()) 11 | { 12 | return 1; 13 | } 14 | 15 | file.seekg(0, std::ios::end); 16 | std::size_t size = file.tellg(); 17 | 18 | std::cout << size << std::endl; 19 | 20 | file.close(); 21 | } 22 | 23 | return 0; 24 | } -------------------------------------------------------------------------------- /practicum/7/Additional-01/Classwork/Task-2/Source.cpp: -------------------------------------------------------------------------------- 1 | #include "TaxiCentral.h" 2 | #include 3 | 4 | int main() { 5 | TaxiCentral OK("OK SuperShano"); 6 | 7 | OK.addTaxiDriver("Misho Volana", 100); 8 | OK.addTaxiDriver("Sasho Shefa", 1000); 9 | 10 | OK.makeOrder("FMI", "Rektorata"); 11 | OK.makeOrder("FMI", "Studentski", "Sasho Shefa"); 12 | 13 | OK.printOrders(); 14 | OK.printTaxiDrivers(); 15 | 16 | std::cout << OK; 17 | 18 | OK.cancelOrder("FMI", "Rektorata"); 19 | 20 | std::cout << OK; 21 | 22 | return 0; 23 | } -------------------------------------------------------------------------------- /practicum/3/14 - 03.06.2022/MeatDish.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Dish.h" 3 | enum class Meat { 4 | Beef, 5 | Pork, 6 | Chicken 7 | }; 8 | 9 | class MeatDish : virtual public Dish { 10 | protected: 11 | Meat meat; 12 | 13 | public: 14 | MeatDish(); 15 | MeatDish(const char **ingredients, int time, int numberOfIngredients, Meat meat); 16 | MeatDish(MeatDish const &other); 17 | 18 | virtual ~MeatDish(); 19 | 20 | virtual void print() const; 21 | 22 | MeatDish operator=(MeatDish const &other); 23 | }; -------------------------------------------------------------------------------- /practicum/4/Week07-Files/snippets/04-binaryFiles/04-02-objects/person.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | const std::size_t MAX_NAME_SIZE = 50; 7 | 8 | class Person 9 | { 10 | private: 11 | char firstName[MAX_NAME_SIZE]; 12 | char lastName[MAX_NAME_SIZE]; 13 | unsigned int age; 14 | 15 | public: 16 | Person(); 17 | Person(const char* firstName, const char* lastName, const unsigned int age); 18 | 19 | friend std::ostream& operator << (std::ostream& out, const Person& person); 20 | }; -------------------------------------------------------------------------------- /practicum/2/09-templates/solutions/point.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | using std::ostream; 4 | 5 | class Point { 6 | int x, y; 7 | 8 | public: 9 | Point(int x = 0, int y = 0); 10 | Point(Point const &); 11 | 12 | Point &operator=(Point const &); 13 | bool operator>(Point const); 14 | bool operator==(Point const); 15 | friend ostream &operator<<(ostream &, Point const &); 16 | 17 | void setX(int _x) { x = _x; }; 18 | void setY(int _y) { x = _y; }; 19 | int getX() const { return x; }; 20 | int getY() const { return y; }; 21 | }; 22 | -------------------------------------------------------------------------------- /practicum/4/Week07-Files/snippets/02-readingFromTextFile/02-04-readingObjects/person.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | const std::size_t MAX_NAME_SIZE = 50; 7 | 8 | class Person 9 | { 10 | private: 11 | char firstName[MAX_NAME_SIZE]; 12 | char lastName[MAX_NAME_SIZE]; 13 | unsigned int age; 14 | 15 | public: 16 | Person(); 17 | 18 | friend std::istream& operator >> (std::istream& in, Person& person); 19 | friend std::ostream& operator << (std::ostream& out, const Person& person); 20 | }; -------------------------------------------------------------------------------- /practicum/2/02-class-constructor/solutions/Beer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | const int MAX_BRAND_LEN = 128; 6 | 7 | class Beer 8 | { 9 | private: 10 | char brand[MAX_BRAND_LEN]; 11 | unsigned volume; 12 | 13 | public: 14 | Beer(); 15 | Beer(const char* newBrand, unsigned newVolume); 16 | 17 | void setVolume(unsigned newVolume); 18 | void setBrand(const char* newBrand); 19 | 20 | unsigned getVolume()const; 21 | const char* getBrand()const; 22 | 23 | void print()const; 24 | 25 | }; -------------------------------------------------------------------------------- /practicum/4/Week14-UnitTests/lab/README.md: -------------------------------------------------------------------------------- 1 | # Unit тестове 2 | 3 | ## Задача 1 :one::one::two::three::five::eight:... 4 | Използвайки принципа на **TDD** *(Test Driven Development)*, реализирайте клас `FibonacciSolver`, съдържащ единствен метод `int getNthFibonacciNumber(int n)`, който намира `N`-тото число на Фибоначи. Ако е подадено невалидно число, хвърлете подходящо изключение. 5 | 6 | ## Задача 2 :capital_abcd::abcd: 7 | Напишете подходящи **unit тестове** за класа `MyString`, разположен в папката `triffon/oop-2021-22/practicum/4/Week14-UnitTests/lab/MyString`. -------------------------------------------------------------------------------- /practicum/4/Week14-UnitTests/snippets/04-TDD/tests.cpp: -------------------------------------------------------------------------------- 1 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 2 | #include "../doctest.h" 3 | #include "factorielSolver.h" 4 | 5 | TEST_CASE("basic") 6 | { 7 | FactorielSolver solver; 8 | 9 | CHECK(solver.solve(0) == 1); 10 | CHECK(solver.solve(1) == 1); 11 | 12 | CHECK(solver.solve(3) == 6); 13 | CHECK(solver.solve(4) == 24); 14 | CHECK(solver.solve(2) == 2); 15 | 16 | CHECK_THROWS_AS(solver.solve(-5), std::invalid_argument); 17 | 18 | CHECK(solver.solve(20) == 2432902008176640000); 19 | } -------------------------------------------------------------------------------- /practicum/3/13 - 27.05.2022/main.cpp: -------------------------------------------------------------------------------- 1 | #include "JSON.hpp" 2 | #include 3 | 4 | int main() { 5 | JSONObj tefter; 6 | tefter.m["age"] = new JSONNumber(12); 7 | JSONObj object; 8 | object.m["name"] = new JSONString("pesho"); 9 | object.m["age"] = new JSONNumber(42); 10 | object.m["tefter"] = &tefter; 11 | object.m["array"] = new JSONArr(std::vector{new JSONNumber(1), new JSONArr(std::vector())}); 12 | object.print(std::cout); 13 | 14 | std::cout << "Hello World!\n"; 15 | } 16 | -------------------------------------------------------------------------------- /practicum/7/Week-09-Static-and-Templates/Separate Compilation/Array.h: -------------------------------------------------------------------------------- 1 | #ifndef __ARRAY__HEADER__INCLUDED__ 2 | #define __ARRAY__HEADER__INCLUDED__ 3 | #include 4 | 5 | template 6 | class Array { 7 | public: 8 | Array(); 9 | ~Array(); 10 | 11 | void add(const T& element); 12 | void print(); 13 | 14 | private: 15 | T* arr; 16 | size_t size; 17 | }; 18 | 19 | #include "Array.inc" 20 | #endif 21 | 22 | // Малко повече обяснение за проблемите 23 | //https://stackoverflow.com/questions/9191210/templates-and-separate-compilation 24 | 25 | -------------------------------------------------------------------------------- /practicum/4/Week06-FriendFunctionsAndGitHub/lab/solutions/Task02/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "WashingMachine.h" 4 | 5 | int main() 6 | { 7 | int n; 8 | std::cout << "n = "; 9 | std::cin >> n; 10 | 11 | WashingMachine optimal; 12 | std::cin >> optimal; 13 | 14 | for (int i = 1; i < n; i++) 15 | { 16 | WashingMachine newMachine; 17 | 18 | std::cin >> newMachine; 19 | 20 | if (newMachine > optimal) 21 | { 22 | optimal = newMachine; 23 | } 24 | } 25 | 26 | std::cout << optimal; 27 | 28 | return 0; 29 | } -------------------------------------------------------------------------------- /practicum/3/02 - 04.03.2022/Task 1/worker.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __WORKER_HPP 2 | #define __WORKER_HPP 3 | 4 | class Worker { 5 | private: 6 | char *name = nullptr; 7 | double salary; 8 | Worker *boss; 9 | 10 | public: 11 | Worker(); 12 | Worker(const char *name, double salary, Worker *boss); 13 | Worker(const Worker &o); 14 | ~Worker(); 15 | 16 | const char *getName() const; 17 | 18 | void setName(const char *name); 19 | 20 | void printCEO() const; 21 | 22 | Worker &operator=(const Worker &o); 23 | }; 24 | 25 | #endif // __WORKER_HPP 26 | -------------------------------------------------------------------------------- /practicum/4/Week08-MidExam1Preparation/solutions/main.cpp: -------------------------------------------------------------------------------- 1 | #include "University.h" 2 | 3 | #include 4 | 5 | int main() 6 | { 7 | std::ofstream file("temp.txt", std::ios::trunc); 8 | 9 | if (!file.is_open()) 10 | { 11 | std::cout << "Error!"; 12 | return 1; 13 | } 14 | 15 | University u; 16 | 17 | Student p("Pesho", 82214, 4, 6.00); 18 | Student l("Lubo", 82197, 4, 6.00); 19 | 20 | u += p; 21 | u += l; 22 | 23 | file << u; 24 | 25 | file.close(); 26 | 27 | return 0; 28 | } -------------------------------------------------------------------------------- /practicum/7/Week-05-Big-four/Classwork/MyString.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | class MyString 4 | { 5 | private: 6 | char* str; 7 | long unsigned int mCapacity; 8 | void resize(); 9 | public: 10 | MyString(const char* str = "\0"); 11 | MyString(const MyString& source); 12 | MyString& operator=(const MyString& rhs); 13 | ~MyString(); 14 | 15 | bool empty() const; 16 | char& at(unsigned int pos); 17 | unsigned int size() const; 18 | unsigned int capacity() const; 19 | const char* c_str() const; 20 | void push_back(char c); 21 | }; -------------------------------------------------------------------------------- /practicum/4/Week05-MoreOperatorOverloading/snippets/01-operatorPlus/money.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class Money 4 | { 5 | private: 6 | unsigned int levs; 7 | unsigned int stotinkas; 8 | 9 | public: 10 | Money(const unsigned int levs, const unsigned int stotinkas); 11 | 12 | bool operator == (const Money& other) const; 13 | bool operator != (const Money& other) const; 14 | bool operator < (const Money& other) const; 15 | 16 | Money& operator += (const Money& other); 17 | Money operator + (const Money& other) const; 18 | 19 | void print() const; 20 | }; -------------------------------------------------------------------------------- /practicum/4/Week06-FriendFunctionsAndGitHub/snippets/02-operatorsInAndOut/money.cpp: -------------------------------------------------------------------------------- 1 | #include "money.h" 2 | 3 | Money::Money() : levs(0), stotinkas(0) {} 4 | 5 | std::istream& operator >> (std::istream& in, Money& money) 6 | { 7 | std::cout << "Enter levs: "; 8 | in >> money.levs; 9 | std::cout << "Enter stotinkas: "; 10 | in >> money.stotinkas; 11 | 12 | return in; 13 | } 14 | 15 | std::ostream& operator << (std::ostream& out, const Money& money) 16 | { 17 | out << money.levs << " levs and " << money.stotinkas << " stotinkas"; 18 | 19 | return out; 20 | } -------------------------------------------------------------------------------- /practicum/4/Week10-Inheritance/lab/solution/Alcohol.h: -------------------------------------------------------------------------------- 1 | #ifndef ALCOHOL_H 2 | #define ALCOHOL_H 3 | 4 | #include "Drink.h" 5 | 6 | class Alcohol : public Drink { 7 | public: 8 | Alcohol(std::string_view name, const int quantity, std::string_view description, const double price, const ServingType servingType, const double alcoholPercentage); 9 | 10 | const double getAlcoholPercentage() const; 11 | 12 | std::string getInfo() const override; 13 | 14 | MenuItem* clone() const override; 15 | 16 | private: 17 | double m_alcoholPercentage; 18 | }; 19 | 20 | #endif // !ALCOHOL_H 21 | -------------------------------------------------------------------------------- /exercises/1/exercises/04-headers-and-testing/partial_compilation/Makefile: -------------------------------------------------------------------------------- 1 | COMPILER=g++ 2 | VERSION=-std=c++17 3 | FLAGS=-Wall -Wextra -Werror -pedantic 4 | 5 | output: main.o greeter.o world.o 6 | ${COMPILER} main.o greeter.o world.o ${VERSION} ${FLAGS} -o output 7 | 8 | main.o: main.cpp greeter.hpp 9 | ${COMPILER} ${VERSION} ${FLAGS} -c main.cpp 10 | 11 | greeter.o: greeter.hpp greeter.cpp world.hpp 12 | ${COMPILER} ${VERSION} ${FLAGS} -c greeter.cpp 13 | 14 | world.o: world.hpp world.cpp 15 | ${COMPILER} ${VERSION} ${FLAGS} -c world.cpp 16 | 17 | clean: 18 | rm *.o output 19 | -------------------------------------------------------------------------------- /exercises/2/week_11_Inheritance_sample_project/sampleProject/Students.cpp: -------------------------------------------------------------------------------- 1 | #include "Students.h" 2 | 3 | void Students::add(const Student& st) 4 | { 5 | if (students.pushBack(st)) 6 | { 7 | std::cout << "Student: " << st.getName() << "was successfully added\n"; 8 | } 9 | else 10 | { 11 | std::cout << "There was an error when adding student\n"; 12 | } 13 | } 14 | 15 | void Students::dosthOnlyForStudents() const 16 | { 17 | int size = students.getSize(); 18 | for (int i = 0; i < size; i++) 19 | { 20 | students[i].sthSpecificForStudent(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /practicum/4/Week04-EnumsAndOperatorOveloading/snippets/02-enums/book.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "bookType.h" 5 | 6 | const std::size_t MAX_BOOK_NAME_SIZE = 100; 7 | 8 | class Book 9 | { 10 | private: 11 | char name[MAX_BOOK_NAME_SIZE]; 12 | int yearOfPublication; 13 | BookType type; 14 | 15 | public: 16 | Book(); 17 | Book(const char* name, const int yearOfPublication, BookType type); 18 | 19 | const char* getName() const; 20 | BookType getType() const; 21 | 22 | void setType(BookType type); 23 | 24 | void print(); 25 | }; -------------------------------------------------------------------------------- /practicum/4/Week05-MoreOperatorOverloading/snippets/02-operatorMinus/money.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class Money 4 | { 5 | private: 6 | unsigned int levs; 7 | unsigned int stotinkas; 8 | 9 | public: 10 | Money(const unsigned int levs, const unsigned int stotinkas); 11 | 12 | bool operator == (const Money& other) const; 13 | bool operator != (const Money& other) const; 14 | bool operator < (const Money& other) const; 15 | 16 | Money& operator -= (const Money& other); 17 | Money operator - (const Money& other) const; 18 | 19 | void print() const; 20 | }; -------------------------------------------------------------------------------- /practicum/7/Week-1/ClassWork/question.txt: -------------------------------------------------------------------------------- 1 | Какъв е типа? 2 | 3 | int* - pointer to int 4 | int const * - pointer to const int 5 | int * const - const pointer to int 6 | int const * const - const pointer to const int 7 | 8 | If you want to go really crazy you can do things like this: 9 | 10 | int ** - pointer to pointer to int 11 | int ** const - const pointer to pointer to int 12 | int * const * - a pointer to a const pointer to int 13 | int const ** - pointer to pointer to a const int 14 | int * const * const - const pointer to a const pointer to an int -------------------------------------------------------------------------------- /lectures/1/player/bot.cpp: -------------------------------------------------------------------------------- 1 | #include "bot.hpp" 2 | 3 | Bot::Bot(char const* _name, unsigned _score, 4 | char const* _algorithm, double _threshold, 5 | unsigned _difficulty) : 6 | Player(_name, _score), 7 | AI(_algorithm, _threshold), 8 | difficulty(_difficulty) {} 9 | 10 | void Bot::print(std::ostream& os) const { 11 | Player::print(os); 12 | printDirect(os); 13 | } 14 | 15 | void Bot::printDirect(std::ostream& os) const { 16 | os << " и е бот с трудност " << getDifficulty(); 17 | os << ", използващ "; 18 | AI::print(os); 19 | } 20 | -------------------------------------------------------------------------------- /practicum/3/13 - 27.05.2022/JSONArr.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "JSONEntry.hpp" 3 | #include 4 | 5 | class JSONArr : public JSONEntry { 6 | public: 7 | std::vector arr; 8 | JSONArr(std::vector arr); 9 | virtual void print(std::ostream &out) { 10 | out << "[ "; 11 | for (auto &x : arr) { 12 | x->print(out); 13 | out << ", "; 14 | } 15 | out << "]"; 16 | } 17 | virtual ~JSONArr() = default; 18 | }; 19 | 20 | JSONArr::JSONArr(std::vector arr) { 21 | this->arr = arr; 22 | } -------------------------------------------------------------------------------- /practicum/7/Week-10-Inheritance/Solutions/Task3/CarPart.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | class CarPart 5 | { 6 | static size_t nextId; 7 | size_t id; 8 | char* manufacturer; 9 | char* description; 10 | public: 11 | friend std::ostream& operator<<(std::ostream& os, const CarPart& obj); 12 | void setManufacturer(const char* manu); 13 | void setDescription(const char* desc); 14 | 15 | CarPart(); 16 | CarPart(const char* manu, const char* desc); 17 | CarPart(const CarPart& src); 18 | CarPart& operator=(const CarPart& rhs); 19 | ~CarPart(); 20 | }; 21 | 22 | -------------------------------------------------------------------------------- /practicum/4/Week07-Files/snippets/04-binaryFiles/04-02-objects/person.cpp: -------------------------------------------------------------------------------- 1 | #include "person.h" 2 | #include 3 | #include 4 | 5 | Person::Person(const char* firstName, const char* lastName, const unsigned int age) : age(age) 6 | { 7 | strcpy(this->firstName, firstName); 8 | strcpy(this->lastName, lastName); 9 | } 10 | 11 | Person::Person() : Person("", "", 0) {} 12 | 13 | std::ostream& operator << (std::ostream& out, const Person& person) 14 | { 15 | out << person.firstName << " " << person.lastName << ", " << person.age << " years old"; 16 | 17 | return out; 18 | } -------------------------------------------------------------------------------- /practicum/7/Additional-01/Classwork/Task-1/Bus.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | class Bus 4 | { 5 | private: 6 | char *licensePlate; 7 | unsigned capacity; 8 | unsigned pasangers; 9 | void copyFrom(const Bus &source); 10 | void erase(); 11 | 12 | public: 13 | Bus(const char *plate = "\0", unsigned cap = 10, unsigned pas = 0); 14 | Bus(const Bus &source); 15 | Bus &operator=(const Bus &rhs); 16 | Bus(Bus &&src); 17 | Bus &operator=(Bus &&rhs); 18 | ~Bus(); 19 | 20 | bool sitPassanger(); 21 | bool full() const; 22 | }; 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /practicum/3/10 - 13.05.2022/Axe.cpp: -------------------------------------------------------------------------------- 1 | #include "Axe.h" 2 | 3 | Axe::Axe() : Weapon(), Melee() {} 4 | 5 | Axe::Axe(int speed, const char *name, double damage) : Weapon(name, damage), Melee(speed, name, damage) {} 6 | 7 | Axe::Axe(const Axe &other) : Weapon(other), Melee(other) {} 8 | 9 | Axe &Axe::operator=(const Axe &other) { 10 | Melee::operator=(other); 11 | return *this; 12 | } 13 | Axe::~Axe() {} 14 | 15 | void Axe::attack(const char *target) { 16 | std::cout << "Axe attacks target " << target << std::endl; 17 | } 18 | 19 | Weapon *Axe::clone() const { 20 | return new Axe(*this); 21 | } -------------------------------------------------------------------------------- /practicum/7/Additional-02/Suitcase/Pants.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ClothingItem.h" 3 | 4 | class Pants : public ClothingItem { 5 | public: 6 | Pants(const String& color, const String& size, size_t price, size_t length) 7 | :ClothingItem(color, size, price), length(length) {} 8 | 9 | virtual Type getType() const { 10 | return Type::PANTS; 11 | } 12 | 13 | virtual void print(std::ostream& out) const { 14 | ClothingItem::print(out); 15 | out << length << "\n"; 16 | } 17 | 18 | virtual ClothingItem* clone() { 19 | return new Pants(*this); 20 | } 21 | 22 | private: 23 | size_t length; 24 | }; -------------------------------------------------------------------------------- /practicum/2/11-polymorphism/solutions/Triangle.cpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Triangle.h" 3 | #include "MathFormulas.hpp" 4 | 5 | Triangle::Triangle(Point2D _a, Point2D _b, Point2D _c) : a(_a), b(_b), c(_c) {} 6 | 7 | double Triangle::getPerimeter() const 8 | { 9 | double distanceAB = Formulas::getDistance2D(a, b); 10 | double distanceAC = Formulas::getDistance2D(a, c); 11 | double distanceBC = Formulas::getDistance2D(b, c); 12 | 13 | double perimeter = distanceAB + distanceAC + distanceBC; 14 | return perimeter; 15 | } 16 | 17 | Shape* Triangle::clone() 18 | { 19 | return new Triangle(*this); 20 | } 21 | -------------------------------------------------------------------------------- /practicum/4/Week07-Files/lab/solutions/task01.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | const std::size_t MAX_LINE_SIZE = 1024; 5 | 6 | int main () 7 | { 8 | std::ifstream file("task01.cpp"); 9 | 10 | if (!file.is_open()) 11 | { 12 | std::cout << "Problem while opening the file!" << std::endl; 13 | return 1; 14 | } 15 | 16 | char buffer[MAX_LINE_SIZE]; 17 | while (!file.eof()) 18 | { 19 | file.getline(buffer, MAX_LINE_SIZE); 20 | 21 | std::cout << buffer << std::endl; 22 | } 23 | 24 | file.close(); 25 | 26 | return 0; 27 | } -------------------------------------------------------------------------------- /practicum/4/Week09-StaticAndTemplates/lab/solutions/computerShop.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "computer.h" 4 | #include "list.h" 5 | #include 6 | 7 | typedef bool (*filterFunction) (const Computer& computer); 8 | 9 | class ComputerShop 10 | { 11 | private: 12 | std::string name; 13 | List computers; 14 | 15 | public: 16 | ComputerShop(const std::string& name); 17 | 18 | void addComputer(const Computer& computer); 19 | void print(); 20 | void buyComputer(const std::string& brand, double customerMoney); 21 | 22 | List filter(filterFunction func); 23 | }; -------------------------------------------------------------------------------- /practicum/4/Week11-AbstractClassesAndPolymorphism/lab/solution/Bed.h: -------------------------------------------------------------------------------- 1 | #ifndef BED_H 2 | #define BED_H 3 | 4 | #include "Furniture.h" 5 | 6 | class Bed : public Furniture { 7 | public: 8 | Bed(const double height = 0, const double width = 0, const double length = 0, const int quantity = 0); 9 | 10 | const std::string getInfo() const override; 11 | 12 | const std::string getStrComparator() const override; 13 | 14 | Furniture* clone() override; 15 | 16 | protected: 17 | double calculatePrice() const override; 18 | 19 | private: 20 | const double PRICE_MULTIPLIER = 22; 21 | }; 22 | 23 | #endif // !BED_H 24 | -------------------------------------------------------------------------------- /practicum/7/Week-05-Big-four/Assignments.md: -------------------------------------------------------------------------------- 1 | # Assignments 2 | 3 | ## Task 1. 4 | Реализирайте клас `MyString`, който има голяма четворка и повечето функции, които `std::string` предоставя, спрямо материала, който сте взели до момента на лекции. 5 | Например: 6 | - size() 7 | - capacity() 8 | - c_str() 9 | - at(unsigned indx) 10 | - push_back(char c) 11 | - pop_back() 12 | - find(char c, unsigned startPos = 0) 13 | - empty() 14 | - substr(unsigned pos = 0, unsigned n = 0) 15 | - append(const MyString& str) 16 | - append(const char* str) 17 | 18 | ### Task 1.1 19 | Напишете тестове за функциите, които сте реализирали. -------------------------------------------------------------------------------- /practicum/4/Week04-EnumsAndOperatorOveloading/snippets/01-separateCompilation/library.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "book.h" 4 | 5 | class Library 6 | { 7 | private: 8 | Book* books; 9 | std::size_t size; 10 | std::size_t capacity; 11 | 12 | void deallocate(); 13 | void copy(const Library& other); 14 | void resize(); 15 | 16 | public: 17 | Library(); 18 | Library(const Library& other); 19 | Library& operator = (const Library& other); 20 | ~Library(); 21 | 22 | void addBook(const Book& toAdd); 23 | bool removeBook(const char* name); 24 | void printInfo(); 25 | }; -------------------------------------------------------------------------------- /practicum/4/Week10-Inheritance/lab/solution/MenuItem.h: -------------------------------------------------------------------------------- 1 | #ifndef MENUITEM_H 2 | #define MENUITEM_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class MenuItem { 9 | public: 10 | MenuItem(std::string_view name, const int quantity, std::string_view description, const double price); 11 | 12 | const double getPrice() const; 13 | 14 | virtual std::string getInfo() const; 15 | 16 | virtual MenuItem* clone() const; 17 | 18 | protected: 19 | std::string m_name; 20 | int m_quantity; 21 | std::string m_description; 22 | double m_price; 23 | }; 24 | 25 | #endif // !MENUITEM_H 26 | -------------------------------------------------------------------------------- /practicum/7/Additional-02/Suitcase/Dress.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ClothingItem.h" 3 | 4 | class Dress : public ClothingItem { 5 | public: 6 | Dress(const String& color, const String& size, size_t price, size_t length) 7 | : ClothingItem(color, size, price), length(length) 8 | {} 9 | 10 | virtual Type getType() const { 11 | return Type::DRESS; 12 | } 13 | 14 | virtual void print(std::ostream& out) const { 15 | ClothingItem::print(out); 16 | out << length << "\n"; 17 | } 18 | 19 | virtual ClothingItem* clone() { 20 | return new Dress(*this); 21 | } 22 | 23 | private: 24 | size_t length; 25 | }; -------------------------------------------------------------------------------- /practicum/7/Week-1/Solutions/Task-3/StudentsBook.h: -------------------------------------------------------------------------------- 1 | const int maxSubjectNameLen = 40; 2 | const int maxSubjects = 100; 3 | const int maxStringLen = 50; 4 | 5 | struct Subject 6 | { 7 | char name[maxSubjectNameLen]; 8 | double grade; 9 | }; 10 | 11 | struct StudentsBook 12 | { 13 | int failedExamsCounter = 0; //or we must count all subject in a different method 14 | double currentGradesSum = 0; //or we need O(n) traversal of all subjects 15 | 16 | int currCounter = 0; 17 | Subject subjects[maxSubjects]; 18 | char name[maxStringLen]; 19 | char facultyNumber[maxStringLen]; 20 | }; 21 | 22 | -------------------------------------------------------------------------------- /practicum/3/02 - 04.03.2022/Task 1/company.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __COMPANY_HPP 2 | #define __COMPANY_HPP 3 | 4 | #include "team.hpp" 5 | 6 | class Company { 7 | private: 8 | char *name; 9 | Team *teams; 10 | size_t numberTeams; 11 | 12 | public: 13 | Company(); 14 | Company(const char *name, const Team *teams, size_t numberTeams); 15 | Company(const Company &a); 16 | ~Company(); 17 | 18 | const char *getName() const; 19 | void setName(const char *name); 20 | bool hasEmployee(const char *name); 21 | 22 | Company &operator=(const Company &a); 23 | }; 24 | 25 | #endif // __COMPANY_HPP 26 | -------------------------------------------------------------------------------- /practicum/4/Week09-StaticAndTemplates/snippets/01-staticVariables.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | class Book 5 | { 6 | private: 7 | static int counter; 8 | unsigned int id; 9 | 10 | public: 11 | Book() 12 | { 13 | this->id = counter++; 14 | std::cout << "I am book #" << this->id << std::endl; 15 | } 16 | }; 17 | 18 | int Book::counter = 1000; 19 | 20 | Book globalBook; 21 | 22 | int main () 23 | { 24 | Book stackBook; 25 | static Book staticBook; 26 | 27 | Book* dynamicBook = new Book; 28 | 29 | delete dynamicBook; 30 | 31 | return 0; 32 | } -------------------------------------------------------------------------------- /practicum/4/Week10-Inheritance/lab/solution/Engine.h: -------------------------------------------------------------------------------- 1 | #ifndef ENGINE_H 2 | #define ENGINE_H 3 | 4 | #include 5 | 6 | #include "Menu.h" 7 | 8 | class Engine { 9 | public: 10 | static Engine& getInstance(); 11 | 12 | void run(); 13 | 14 | private: 15 | Engine(); 16 | Engine(const Engine&) = delete; 17 | 18 | Engine& operator=(const Engine&) = delete; 19 | 20 | private: 21 | Menu* m_menu; 22 | 23 | const std::string getMenuItemType() const; 24 | 25 | void printOperations() const; 26 | void getOperation(char&) const; 27 | void executeOperation(const char); 28 | }; 29 | 30 | #endif // !ENGINE_H 31 | 32 | -------------------------------------------------------------------------------- /practicum/7/Week-12-Polymorphism/Task-1/Source.cpp: -------------------------------------------------------------------------------- 1 | #include "ShapeContainer.h" 2 | #include "Rectangle.h" 3 | #include "Rhombus.h" 4 | #include "Triangle.h" 5 | #include "Circle.h" 6 | 7 | int main() { 8 | ShapeContainer container; 9 | 10 | Rectangle r(10.5, 1.2, "blue", 10, 2); 11 | Triangle t(1, 1.1, "green", 2, 3, 4, 2, 1, 1); 12 | Circle c(1, 2, "red", 10); 13 | Rhombus rh(4.3, 5.5, "orange", 1, 20); 14 | 15 | container.addShape(&r); 16 | container.addShape(&t); 17 | container.addShape(&c); 18 | container.addShape(&rh); 19 | 20 | container.print(); 21 | container.printPerimeters(); 22 | container.printSurfaces(); 23 | } -------------------------------------------------------------------------------- /practicum/4/Week04-EnumsAndOperatorOveloading/lab/solution/date.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class Date 6 | { 7 | private: 8 | std::uint8_t m_day; 9 | std::uint8_t m_month; 10 | std::uint16_t m_year; 11 | 12 | void printNumberWithLeadingZero(unsigned int number) const; 13 | 14 | public: 15 | Date(unsigned int day, unsigned int month, unsigned int year); 16 | 17 | unsigned int day() const; 18 | unsigned int month() const; 19 | unsigned int year() const; 20 | 21 | bool operator==(const Date& rhs) const; 22 | bool operator<(const Date& rhs) const; 23 | 24 | void print() const; 25 | }; -------------------------------------------------------------------------------- /practicum/7/Week-12-Polymorphism/Task-1/Rectangle.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Shape.h" 3 | class Rectangle : public Shape { 4 | public: 5 | Rectangle(double x, double y, const char* color, double a, double b) 6 | :Shape(x, y, color), a(a), b(b) {} 7 | 8 | virtual void print() const override { 9 | std::cout << "Rectangle\n"; 10 | Shape::print(); 11 | std::cout << "a: " << a << ", b: " << b << "\n\n"; 12 | } 13 | 14 | virtual double perimeter() const override { 15 | return (a + b) * 2; 16 | } 17 | 18 | virtual double surface() const override { 19 | return a * b; 20 | } 21 | 22 | private: 23 | double a; 24 | double b; 25 | }; -------------------------------------------------------------------------------- /practicum/7/Week-05-Big-four/Theory/Overloading assignment operator.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | /* 6 | - Copy assignment operator (=) 7 | - C++ provides a default assignment operator used ofr assigning one object to another 8 | Mystring s1 {"Frank"}; 9 | Mystring s2 = s1; //NOT assignment because its the same as Mystring s2{s1}; (initialization statement) 10 | ,but: 11 | s2 = s1 ASSIGNMENT 12 | 13 | - Default is memberwise assignment (shallow copy) 14 | - if we have a raw pointer data member we must deep copy 15 | */ 16 | 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /practicum/7/Week-09-Static-and-Templates/Separate Compilation/Array.inc: -------------------------------------------------------------------------------- 1 | const size_t MAX_SIZE = 10; 2 | 3 | template 4 | inline Array::Array() { 5 | arr = new T[MAX_SIZE]; 6 | size = 0; 7 | } 8 | 9 | template 10 | inline Array::~Array() { 11 | delete[] arr; 12 | } 13 | 14 | template 15 | inline void Array::add(const T& element) { 16 | if (size >= MAX_SIZE) 17 | return; 18 | 19 | arr[size] = element; 20 | size++; 21 | } 22 | 23 | template 24 | inline void Array::print() { 25 | for (int i = 0; i < size; ++i) 26 | std::cout << arr[i] << ' '; 27 | 28 | std::cout << std::endl; 29 | } -------------------------------------------------------------------------------- /practicum/3/02 - 04.03.2022/Task 1/team.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TEAM_HPP 2 | #define __TEAM_HPP 3 | 4 | #include "worker.hpp" 5 | 6 | class Team { 7 | private: 8 | char *name; 9 | Worker *employees; 10 | size_t numberEmployees; 11 | 12 | public: 13 | Team(); 14 | Team(const char *name, const Worker *employees, size_t numberEmployees); 15 | Team(const Team &a); 16 | ~Team(); 17 | 18 | const Worker *getEmployees() const; 19 | size_t getNumberEmployees() const; 20 | 21 | const char *getName() const; 22 | void setName(const char *name); 23 | 24 | Team &operator=(const Team &o); 25 | }; 26 | 27 | #endif // __TEAM_HPP 28 | -------------------------------------------------------------------------------- /practicum/3/10 - 13.05.2022/README.md: -------------------------------------------------------------------------------- 1 | # Задачи за ООП практикум на 3та група - 13.05.2022 2 | 3 | ## Задача 1 4 | * Да се напише абстрактен клас `Weapon`. Всяко оръжие се характеризира с име и поражения и има метод `attack`. 5 | * Да се напише абстрактен клас `Melee`. Всяко меле оръжие се характеризира със същите неща като едно оръжие, но има и скорост. 6 | * Да се напише абстрактен клас `Ranged`. Всяко далекобойно оръжие се характеризира със същите неща като едно оръжие, но има и обхват. 7 | * Да се напише клас `Axe`, който наследява `Melee`. 8 | * Да се напише клас `Bow`, който наследява `Rangedd`. 9 | * Да се напише клас `Japanka`, който наследява и `Melee` и `Rangedd`. -------------------------------------------------------------------------------- /practicum/4/Week14-UnitTests/snippets/01-OurFirstUniTests/calculator.cpp: -------------------------------------------------------------------------------- 1 | #include "calculator.h" 2 | #include 3 | 4 | double Calculator::sum(double first, double second) 5 | { 6 | return first + second; 7 | } 8 | 9 | double Calculator::diff(double first, double second) 10 | { 11 | return first - second; 12 | } 13 | 14 | double Calculator::divide(double first, double second) 15 | { 16 | if (second == 0) 17 | { 18 | throw std::invalid_argument("cannot divide by 0"); 19 | } 20 | return first / second; 21 | } 22 | 23 | double Calculator::multiply(double first, double second) 24 | { 25 | return first * second; 26 | } -------------------------------------------------------------------------------- /practicum/7/Week-12-Polymorphism/Task-1/Circle.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Shape.h" 3 | class Circle: public Shape { 4 | public: 5 | Circle(double x, double y, const char* color, double diameter) 6 | :Shape(x, y, color), 7 | diameter(diameter) {} 8 | 9 | virtual void print() const override { 10 | std::cout << "Circle\n"; 11 | Shape::print(); 12 | std::cout << "d: " << diameter << "\n\n"; 13 | } 14 | 15 | virtual double perimeter() const override { 16 | return acos(-1) * diameter; 17 | } 18 | 19 | virtual double surface() const override { 20 | return cos(-1) * diameter * diameter / 4; 21 | } 22 | 23 | private: 24 | double diameter; 25 | }; -------------------------------------------------------------------------------- /exercises/2/PreparationForTest_2/Classroom.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Student.h" 3 | 4 | using predicate = bool (*)(const Student&); 5 | 6 | class Classroom 7 | { 8 | private: 9 | Student* students; 10 | int capacity; 11 | int size; 12 | void copy(const Classroom& other); 13 | void resize(); 14 | public: 15 | Classroom(); 16 | Classroom(int capacity); 17 | Classroom(const Classroom& other); 18 | Classroom& operator =(const Classroom& other); 19 | ~Classroom(); 20 | void addStudent(const Student& newStudent); 21 | void print() const; 22 | void invite(predicate p) const; 23 | //void sort(bool gabd, bool ascending = true); 24 | }; -------------------------------------------------------------------------------- /practicum/7/Week-12-Polymorphism/Task-1/Rhombus.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Shape.h" 3 | class Rhombus : public Shape { 4 | public: 5 | Rhombus(double x, double y, const char* color, double a, double angle) 6 | :Shape(x, y, color), 7 | a(a), angle(angle) {} 8 | 9 | virtual void print() const override { 10 | std::cout << "Rhombus\n"; 11 | Shape::print(); 12 | std::cout << "a: " << a << ", angle: " << angle << "\n\n"; 13 | } 14 | 15 | virtual double perimeter() const override { 16 | return 4 * a; 17 | } 18 | 19 | virtual double surface() const override { 20 | return a * a * sin(angle); 21 | } 22 | 23 | private: 24 | double a; 25 | double angle; 26 | }; -------------------------------------------------------------------------------- /practicum/3/06, 07 - 08.04.2022/Task 1 & Task 2/Event.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "DateTime.hpp" 4 | 5 | class Event { 6 | char *name; 7 | 8 | public: 9 | DateTime start; 10 | DateTime end; 11 | 12 | Event(); 13 | Event(const char *name, const DateTime &start, const DateTime &end); 14 | Event(const Event &o); 15 | ~Event(); 16 | 17 | const char *getName() const; 18 | void setName(const char *name); 19 | 20 | void serialize(std::ostream &out) const; 21 | void deserialize(std::istream &in); 22 | 23 | Event &operator=(const Event &o); 24 | 25 | friend std::ostream &operator<<(std::ostream &out, const Event &d); 26 | }; -------------------------------------------------------------------------------- /exercises/2/week_6_friendFuncAndString/String.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | class String { 6 | private: 7 | char* myString; 8 | void copy(const String& other); 9 | void erase(); 10 | public: 11 | String(); 12 | String(const char* str); 13 | String(const String& other); 14 | String& operator =(const String& other); 15 | ~String(); 16 | size_t getSize() const; 17 | void print() const; 18 | void add(const char* str); 19 | String operator+(const String& other); 20 | friend std::ostream& operator << (std::ostream& out, const String& str); 21 | friend std::istream& operator >> (std::istream& in, const String& str); 22 | }; -------------------------------------------------------------------------------- /practicum/3/04 - 18.03.2022/Task 1/Vector3D.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define EPS 1e-3 4 | 5 | class Vector3D { 6 | public: 7 | double x; 8 | double y; 9 | double z; 10 | 11 | Vector3D(); 12 | Vector3D(double x, double y, double z); 13 | 14 | double getLenght() const; 15 | void normalize(); 16 | }; 17 | 18 | Vector3D sum(const Vector3D &v1, const Vector3D &v2); 19 | Vector3D product(const Vector3D &v, double multiple); 20 | Vector3D div(const Vector3D &v, double divisor); 21 | Vector3D diff(const Vector3D &v1, const Vector3D &v2); 22 | double productScalar(const Vector3D &v1, const Vector3D &v2); 23 | Vector3D productVector(const Vector3D &v1, const Vector3D &v2); -------------------------------------------------------------------------------- /practicum/4/Week07-Files/snippets/02-readingFromTextFile/02-04-readingObjects/person.cpp: -------------------------------------------------------------------------------- 1 | #include "person.h" 2 | #include 3 | 4 | Person::Person() : age(0) 5 | { 6 | strcpy(firstName, ""); 7 | strcpy(lastName, ""); 8 | } 9 | 10 | std::istream& operator >> (std::istream& in, Person& person) 11 | { 12 | in >> person.firstName >> person.lastName >> person.age; 13 | 14 | return in; 15 | } 16 | 17 | std::ostream& operator << (std::ostream& out, const Person& person) 18 | { 19 | out << "First name: " << person.firstName << "\n"; 20 | out << "Last name: " << person.lastName << "\n"; 21 | out << "Age: " << person.age << "\n"; 22 | 23 | return out; 24 | } -------------------------------------------------------------------------------- /lectures/1/player/boss.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __BOSS_HPP 2 | #define __BOSS_HPP 3 | #include "hero.hpp" 4 | #include "bot.hpp" 5 | 6 | class Boss : public Hero, public Bot { 7 | unsigned damage; 8 | public: 9 | Boss(char const* _name = "<някакъв бос>", unsigned _score = 0, 10 | char const* _algorithm = "<неизвестен алгоритъм>", double _threshold = 0.1, 11 | unsigned _level = 20, unsigned _difficulty = 1, unsigned _damage = 10); 12 | Boss* clone() const { return new Boss(*this); } 13 | 14 | unsigned getDamage() const { return damage; } 15 | 16 | void print(std::ostream& os = std::cout) const; 17 | void printDirect(std::ostream& os = std::cout) const; 18 | }; 19 | 20 | #endif -------------------------------------------------------------------------------- /practicum/4/Week09-StaticAndTemplates/lab/solutions/task01.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "list.h" 4 | 5 | int main () 6 | { 7 | List list; 8 | 9 | list.add(2); 10 | list.add(5); 11 | list.add(7); 12 | list.add(-1); 13 | 14 | std::cout << list[2] << std::endl; 15 | 16 | std::cout << list << std::endl; 17 | 18 | List stringList; 19 | 20 | std::cin >> stringList; 21 | std::cout << stringList << std::endl; 22 | 23 | List charList; 24 | 25 | std::ifstream in("charList.txt"); 26 | in >> charList; 27 | 28 | std::ofstream out("charList-res.txt"); 29 | out << charList; 30 | 31 | return 0; 32 | } -------------------------------------------------------------------------------- /practicum/4/Week08-MidExam1Preparation/solutions/University.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Student.h" 4 | 5 | class University 6 | { 7 | private: 8 | Student** data; 9 | size_t capacity; 10 | size_t m_size; 11 | 12 | void reallocate(); 13 | 14 | public: 15 | University(); 16 | ~University(); 17 | void sort(bool(*cmp)(const Student&, const Student&)); 18 | void filter(bool(*pred)(const Student&)); 19 | University& operator +=(const Student& st); 20 | University& operator -=(int fn); 21 | friend std::ostream& operator <<(std::ostream& out, const University &obj); 22 | friend std::istream& operator >>(std::istream& in, University &obj); 23 | 24 | }; -------------------------------------------------------------------------------- /practicum/4/Week14-UnitTests/snippets/00-customException/customException.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | class PepiKNotAvailableException : public std::exception 5 | { 6 | private: 7 | std::string message; 8 | 9 | public: 10 | PepiKNotAvailableException(const std::string& message) : message(message) {} 11 | 12 | const char* what() const noexcept override final 13 | { 14 | return this->message.c_str(); 15 | } 16 | }; 17 | 18 | int main () 19 | { 20 | try 21 | { 22 | throw PepiKNotAvailableException("mnogo tajno"); 23 | } 24 | catch(const std::exception& e) 25 | { 26 | std::cerr << e.what() << '\n'; 27 | } 28 | 29 | return 0; 30 | } -------------------------------------------------------------------------------- /practicum/2/03-big-four/solutions/Vector.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class Vector 4 | { 5 | public: 6 | // Big four 7 | Vector(); 8 | Vector(const Vector& other); 9 | Vector& operator=(const Vector& other); 10 | ~Vector(); 11 | 12 | public: 13 | // Methods 14 | int size(); 15 | int capacity(); 16 | int& at(int index); 17 | void push_back(int element); 18 | void erase(int index); 19 | void reserve(int capacity); 20 | 21 | private: 22 | // Helper methods used in the big four 23 | void copy(const Vector& other); 24 | void clear(); 25 | 26 | private: 27 | // Data members should always be private 28 | int m_size; 29 | int m_capacity; 30 | int* m_arr; 31 | }; 32 | -------------------------------------------------------------------------------- /practicum/4/Week04-EnumsAndOperatorOveloading/snippets/01-separateCompilation/book.cpp: -------------------------------------------------------------------------------- 1 | #include "book.h" 2 | #include 3 | #include 4 | #include 5 | 6 | Book::Book() 7 | { 8 | strcpy(this->name, ""); 9 | this->yearOfPublication = 0; 10 | } 11 | 12 | Book::Book(const char* name, const int yearOfPublication) 13 | { 14 | assert(name != nullptr); 15 | 16 | strcpy(this->name, name); 17 | this->yearOfPublication = yearOfPublication; 18 | } 19 | 20 | const char* Book::getName() 21 | { 22 | return this->name; 23 | } 24 | 25 | void Book::print() 26 | { 27 | assert(this->name != nullptr); 28 | 29 | std::cout << this->name << ", " << this->yearOfPublication << std::endl; 30 | } -------------------------------------------------------------------------------- /practicum/4/Week04-EnumsAndOperatorOveloading/snippets/01-separateCompilation/main.cpp: -------------------------------------------------------------------------------- 1 | #include "library.h" 2 | #include 3 | 4 | int main () 5 | { 6 | Library library; 7 | 8 | library.addBook(Book("Harry Potter", 2001)); 9 | library.addBook(Book("Pod igoto", 1893)); 10 | library.addBook(Book("The Little Prince", 1943)); 11 | library.addBook(Book("The Shining", 1977)); 12 | library.addBook(Book("The Great Gatsby", 1925)); 13 | 14 | library.printInfo(); 15 | 16 | std::cout << std::boolalpha << library.removeBook("Moby-Dick") << std::endl; 17 | std::cout << std::boolalpha << library.removeBook("Pod igoto") << std::endl; 18 | 19 | library.printInfo(); 20 | 21 | return 0; 22 | } -------------------------------------------------------------------------------- /practicum/4/Week07-Files/snippets/02-readingFromTextFile/02-03-charByChar.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main () 5 | { 6 | // i - intput 7 | // f - file 8 | // stream 9 | std::ifstream dadJokes("dadJokes.txt"); 10 | 11 | if (!dadJokes.is_open()) // always check if the opening is successfull 12 | { 13 | std::cout << "Problem while opening the file" << std::endl; 14 | return 1; 15 | } 16 | 17 | // Reading the file char by char 18 | 19 | char ch; 20 | while (!dadJokes.eof()) // reading until end of file 21 | { 22 | dadJokes.get(ch); 23 | std::cout << ch; 24 | } 25 | 26 | dadJokes.close(); 27 | 28 | return 0; 29 | } -------------------------------------------------------------------------------- /practicum/2/11-polymorphism/solutions/ShapeContainer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Shape.h" 3 | #include 4 | 5 | class ShapeContainer 6 | { 7 | public: 8 | ShapeContainer(size_t capacity = 16); 9 | ShapeContainer(const ShapeContainer& other); 10 | ShapeContainer& operator=(const ShapeContainer& other); 11 | ~ShapeContainer(); 12 | 13 | public: 14 | void printPerimeters() const; 15 | void add(Shape* newShape); 16 | 17 | friend std::ifstream& operator>>(std::ifstream& in, ShapeContainer& container); 18 | 19 | private: 20 | void copy(const ShapeContainer& other); 21 | void clean(); 22 | void resize(size_t newCapacity); 23 | 24 | private: 25 | Shape** f_shapes; 26 | size_t f_size; 27 | size_t f_capacity; 28 | }; 29 | -------------------------------------------------------------------------------- /practicum/4/Week06-FriendFunctionsAndGitHub/snippets/01-moreArithmeticOperators/money.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class Money 4 | { 5 | private: 6 | unsigned int levs; 7 | unsigned int stotinkas; 8 | 9 | public: 10 | Money(const unsigned int levs, const unsigned int stotinkas); 11 | 12 | bool operator == (const Money& other) const; 13 | bool operator != (const Money& other) const; 14 | bool operator < (const Money& other) const; 15 | 16 | Money& operator += (const Money& other); 17 | Money operator + (const Money& other) const; 18 | 19 | Money operator + (const unsigned int levs) const; 20 | friend Money operator + (const unsigned int levs, const Money& second); 21 | 22 | void print() const; 23 | }; -------------------------------------------------------------------------------- /practicum/2/08-files/solutions/spacecrafts/Spacecraft.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | class Spacecraft 5 | { 6 | public: 7 | Spacecraft(int year = 0, const char* name = ""); 8 | Spacecraft(std::ifstream& in); 9 | Spacecraft(const Spacecraft& other); 10 | Spacecraft& operator=(const Spacecraft& other); 11 | ~Spacecraft(); 12 | 13 | void serialize(std::ofstream& out) const; 14 | 15 | inline const char* getName() const { return name; } 16 | inline int getYear() const { return year; } 17 | 18 | private: 19 | void copy(const Spacecraft& other); 20 | void clear(); 21 | 22 | int year; 23 | char* name; 24 | }; 25 | 26 | std::ostream& operator<<(std::ostream& out, const Spacecraft& obj); 27 | -------------------------------------------------------------------------------- /practicum/3/10 - 13.05.2022/Melee.cpp: -------------------------------------------------------------------------------- 1 | #include "melee.h" 2 | 3 | Melee::Melee() { 4 | this->speed = 0; 5 | }; 6 | 7 | Melee::Melee(int speed, char const *name, double damage) : Weapon(name, damage) { 8 | this->speed = speed; 9 | }; 10 | 11 | Melee::Melee(const Melee &other) : Weapon(other) { 12 | this->speed = other.speed; 13 | }; 14 | 15 | Melee &Melee::operator=(const Melee &other) { 16 | 17 | if (this != &other) { 18 | Weapon::operator=(other); 19 | this->speed = speed; 20 | } 21 | 22 | return *this; 23 | }; 24 | Melee::~Melee(){}; 25 | 26 | int Melee::getSpeed() const { 27 | return this->speed; 28 | }; 29 | 30 | void Melee::hit() { 31 | std::cout << " Melee weapon hit " << getName() << std::endl; 32 | } -------------------------------------------------------------------------------- /practicum/4/Week03-ClassesAndRuleOf0-3/snippets/01-structVsClass.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | const std::size_t MAX_NAME_SIZE = 50; 5 | 6 | // the default access modifier is 'public' 7 | struct PersonAsStruct 8 | { 9 | int age; 10 | char name[MAX_NAME_SIZE]; 11 | }; 12 | 13 | // the default access modifier is 'private' 14 | class PersonAsClass 15 | { 16 | public: 17 | int age; 18 | char name[MAX_NAME_SIZE]; 19 | }; 20 | 21 | int main () 22 | { 23 | PersonAsStruct structPerson; 24 | structPerson.age = 18; 25 | strcpy(structPerson.name, "Dani"); 26 | 27 | PersonAsClass classPerson; 28 | // classPerson --> we cannot access anything that is not explicitly set as public 29 | 30 | return 0; 31 | } -------------------------------------------------------------------------------- /exercises/2/week_4_taskWithWebServers/ServerFarm.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "WebServer.h" 3 | 4 | class ServerFarm { 5 | private: 6 | WebServer* farm; 7 | unsigned size; 8 | unsigned capacity; 9 | char* name; 10 | void copy(const ServerFarm& other); 11 | void destroy(); 12 | public: 13 | ServerFarm(); 14 | ServerFarm(int capacity); 15 | ServerFarm(const char* _name); 16 | ServerFarm(const ServerFarm& other); 17 | ServerFarm& operator =(const ServerFarm& other); 18 | ~ServerFarm(); 19 | ServerFarm& addServer(const WebServer newServer); 20 | void print() const; 21 | ServerFarm& operator -=(int* address); 22 | int countInNetwork(int address) const; 23 | void findMaxNetwork() const; 24 | ServerFarm& sort(); 25 | 26 | 27 | }; -------------------------------------------------------------------------------- /practicum/4/Week04-EnumsAndOperatorOveloading/snippets/03-operatorOverloading/money.cpp: -------------------------------------------------------------------------------- 1 | #include "money.h" 2 | 3 | Money::Money(const unsigned int levs, const unsigned int stotinkas) 4 | { 5 | this->levs = levs; 6 | this->stotinkas = stotinkas; 7 | } 8 | 9 | bool Money::operator == (const Money& other) const 10 | { 11 | // return this->operator==(other); 12 | 13 | return this->levs == other.levs && this->stotinkas == other.stotinkas; 14 | } 15 | 16 | bool Money::operator != (const Money& other) const 17 | { 18 | return !(*this == other); 19 | } 20 | 21 | bool Money::operator < (const Money& other) const 22 | { 23 | return this->levs < other.levs || 24 | (this->levs == other.levs && this->stotinkas < other.stotinkas); 25 | } -------------------------------------------------------------------------------- /practicum/4/Week07-Files/snippets/02-readingFromTextFile/02-01-wordByWord.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main () 5 | { 6 | // i - intput 7 | // f - file 8 | // stream 9 | std::ifstream dadJokes("dadJokes.txt"); 10 | 11 | if (!dadJokes.is_open()) // always check if the opening is successfull 12 | { 13 | std::cout << "Problem while opening the file" << std::endl; 14 | return 1; 15 | } 16 | 17 | // Reading the file word by word 18 | 19 | char tempWord[100]; 20 | while (!dadJokes.eof()) // reading until end of file 21 | { 22 | dadJokes >> tempWord; 23 | std::cout << tempWord << std::endl; 24 | } 25 | 26 | dadJokes.close(); 27 | 28 | return 0; 29 | } -------------------------------------------------------------------------------- /practicum/4/Week09-StaticAndTemplates/lab/solutions/consultantUtils.cpp: -------------------------------------------------------------------------------- 1 | #include "consultantUtils.h" 2 | 3 | bool ConsultantUtils::isGoodForGaming(const Computer& computer) 4 | { 5 | std::string processor = computer.getProcessor(); 6 | std::size_t video = computer.getVideo(); 7 | double hardDrive = computer.getHardDrive(); 8 | 9 | return (processor == "i5" || processor == "i7") && 10 | (video == 3060 || video == 3070 || video == 3080 || video == 3090) && 11 | (hardDrive >= 512); 12 | } 13 | 14 | bool ConsultantUtils::isGoodForTravel(const Computer& computer) 15 | { 16 | double weight = computer.getWeight(); 17 | double batteryLife = computer.getBatteryLife(); 18 | 19 | return weight <= 2.5 && batteryLife > 6; 20 | } -------------------------------------------------------------------------------- /lectures/1/player/bot.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __BOT_HPP 2 | #define __BOT_HPP 3 | #include "player.hpp" 4 | #include "ai.hpp" 5 | 6 | 7 | class Bot : virtual public Player, public AI { 8 | unsigned difficulty; 9 | 10 | public: 11 | Bot(char const* _name = "<някакъв бот>", unsigned _score = 0, 12 | char const* _algorithm = "<неизвестен алгоритъм>", double _threshold = 0.1, 13 | unsigned _difficulty = 1); 14 | Bot* clone() const { return new Bot(*this); } 15 | 16 | unsigned getDifficulty() const { return difficulty; } 17 | void setDifficulty(unsigned _difficulty) { difficulty = _difficulty; } 18 | 19 | void print(std::ostream& os = std::cout) const; 20 | void printDirect(std::ostream& os = std::cout) const; 21 | }; 22 | 23 | #endif -------------------------------------------------------------------------------- /lectures/1/player/boss.cpp: -------------------------------------------------------------------------------- 1 | #include "boss.hpp" 2 | 3 | Boss::Boss(char const* _name, unsigned _score, 4 | char const* _algorithm, double _threshold, 5 | unsigned _level, unsigned _difficulty, unsigned _damage) 6 | : Player(_name, _score), 7 | Hero("игнорира се", _score, _level), 8 | Bot("също се игнорира", _score, _algorithm, _threshold, _difficulty), 9 | damage(_damage) {} 10 | 11 | void Boss::print(std::ostream& os) const { 12 | Player::print(os); 13 | printDirect(os); 14 | } 15 | 16 | void Boss::printDirect(std::ostream& os) const { 17 | Bot::printDirect(os); 18 | std::cout << " и е бос, който"; 19 | Hero::printDirect(os); 20 | std::cout << " и нанася щети " << getDamage() << std::endl; 21 | } -------------------------------------------------------------------------------- /practicum/4/Week07-Files/snippets/02-readingFromTextFile/02-02-lineByLine.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main () 5 | { 6 | // i - intput 7 | // f - file 8 | // stream 9 | std::ifstream dadJokes("dadJokes.txt"); 10 | 11 | if (!dadJokes.is_open()) // always check if the opening is successfull 12 | { 13 | std::cout << "Problem while opening the file" << std::endl; 14 | return 1; 15 | } 16 | 17 | // Reading the file line by line 18 | 19 | char tempLine[1000]; 20 | while (!dadJokes.eof()) // reading until end of file 21 | { 22 | dadJokes.getline(tempLine, 1000); 23 | std::cout << tempLine << std::endl; 24 | } 25 | 26 | dadJokes.close(); 27 | 28 | return 0; 29 | } -------------------------------------------------------------------------------- /practicum/2/02-class-constructor/solutions/Beer.cpp: -------------------------------------------------------------------------------- 1 | #include "Beer.h" 2 | 3 | Beer::Beer() 4 | { 5 | volume = 0; 6 | brand[0] = '\0'; 7 | } 8 | 9 | Beer::Beer(const char* newBrand, unsigned newVolume) 10 | { 11 | volume = newVolume; 12 | strcpy_s(brand, newBrand); 13 | } 14 | 15 | void Beer::setVolume(unsigned newVolume) 16 | { 17 | volume = newVolume; 18 | } 19 | 20 | void Beer::setBrand(const char* newBrand) 21 | { 22 | strcpy_s(brand, newBrand); 23 | } 24 | 25 | unsigned Beer::getVolume()const 26 | { 27 | return volume; 28 | } 29 | 30 | const char* Beer::getBrand()const 31 | { 32 | return brand; 33 | } 34 | 35 | void Beer::print()const 36 | { 37 | std::cout << "Beer brand is " << brand << ";\nBeer volume is " << volume << "\n"; 38 | } -------------------------------------------------------------------------------- /practicum/2/09-templates/solutions/point.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "point.hpp" 4 | 5 | using std::ostream; 6 | 7 | Point::Point(int _x, int _y) { 8 | x = _x; 9 | y = _y; 10 | } 11 | 12 | Point::Point(Point const &temp) { 13 | x = temp.x; 14 | y = temp.y; 15 | } 16 | 17 | Point &Point::operator=(Point const &temp) { 18 | x = temp.x; 19 | y = temp.y; 20 | 21 | return *this; 22 | } 23 | 24 | bool Point::operator>(Point const temp) { 25 | return x > temp.x || ( x == temp.x && y > temp.y); 26 | } 27 | 28 | bool Point::operator==(Point const temp) { 29 | return x == temp.x && y == temp.y; 30 | } 31 | 32 | ostream &operator<<(ostream &ostr, Point const &temp) { 33 | ostr << temp.x << " " << temp.y; 34 | return ostr; 35 | } 36 | -------------------------------------------------------------------------------- /practicum/4/Week11-AbstractClassesAndPolymorphism/lab/solution/Chair.h: -------------------------------------------------------------------------------- 1 | #ifndef CHAIR_H 2 | #define CHAIR_H 3 | 4 | #include "Furniture.h" 5 | #include "ChairType.h" 6 | 7 | class Chair : public Furniture { 8 | public: 9 | Chair(const double height = 0, const double width = 0, const double length = 0, const int quantity = 0, const ChairType type = ChairType::WOODEN); 10 | 11 | void read(std::istream& in = std::cin) override; 12 | 13 | const std::string getInfo() const override; 14 | 15 | const std::string getStrComparator() const override; 16 | 17 | Furniture* clone() override; 18 | 19 | protected: 20 | double calculatePrice() const override; 21 | 22 | private: 23 | const double PRICE_MULTIPLIER = 9; 24 | 25 | ChairType m_type; 26 | }; 27 | 28 | #endif // !CHAIR_h 29 | -------------------------------------------------------------------------------- /lectures/1/geometry/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "point2d.hpp" 3 | #include "point3d.hpp" 4 | 5 | void testGeometry() { 6 | DPoint2D p, q(1, 3); 7 | p.printnl(); 8 | q.printnl(); 9 | p.read(); 10 | p.printnl(); 11 | std::cout << p.distanceToOrigin() << std::endl; 12 | std::cout << p.distanceTo(q) << std::endl; 13 | p.translate(q); 14 | p.printnl(); 15 | } 16 | 17 | void testGeometry3D() { 18 | Point3D p(1, 3, 8); 19 | p.printnl(); 20 | Point3D q = p; 21 | q.printnl(); 22 | q.read(); 23 | p.translate(q); 24 | std::cout << p.distanceToOrigin() << std::endl; 25 | std::cout << p.distanceTo(q) << std::endl; 26 | } 27 | 28 | int main(int, char**) { 29 | //testGeometry(); 30 | testGeometry3D(); 31 | } 32 | -------------------------------------------------------------------------------- /practicum/4/Week11-AbstractClassesAndPolymorphism/lab/solution/Table.h: -------------------------------------------------------------------------------- 1 | #ifndef TABLE_H 2 | #define TABLE_H 3 | 4 | #include "Furniture.h" 5 | #include "TableType.h" 6 | 7 | class Table : public Furniture { 8 | public: 9 | Table(const double height = 0, const double width = 0, const double length = 0, const int quantity = 0, const TableType type = TableType::LIVING_ROOM); 10 | 11 | void read(std::istream& in = std::cin) override; 12 | 13 | const std::string getInfo() const override; 14 | 15 | const std::string getStrComparator() const override; 16 | 17 | Furniture* clone() override; 18 | 19 | protected: 20 | double calculatePrice() const override; 21 | 22 | private: 23 | const double PRICE_MULTIPLIER = 15; 24 | 25 | TableType m_type; 26 | }; 27 | 28 | #endif // !TABLE_H 29 | -------------------------------------------------------------------------------- /exercises/2/week_8_file_read_write+binary/WebServer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | class WebServer { 5 | private: 6 | char * URL; 7 | int IPv4Address[4]; 8 | char * OS; 9 | void copy(const WebServer& other); 10 | void destroy(); 11 | public: 12 | WebServer(); 13 | WebServer(const WebServer& other); 14 | WebServer& operator =(const WebServer& other); 15 | ~WebServer(); 16 | bool operator <(const WebServer& other); 17 | bool operator ==(const WebServer& other); 18 | bool operator !=(const WebServer& other); 19 | void print() const; 20 | void read(); 21 | 22 | // for exercise: 23 | void save(std::ostream& out); 24 | void read(std::istream& in); 25 | //binary 26 | void saveBin(std::ostream& out); 27 | void readBin(std::istream& in); 28 | }; -------------------------------------------------------------------------------- /lectures/1/player/ai.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __AI_HPP 2 | #define __AI_HPP 3 | 4 | #include 5 | #include "printable.hpp" 6 | 7 | class AI : virtual public Printable { 8 | char* algorithm; 9 | double threshold; 10 | 11 | void setAlgorithm(char const* _algorithm); 12 | public: 13 | 14 | AI(char const* _algorithm = "<неизвестен>", double _threshold = 0); 15 | AI(AI const& other); 16 | AI& operator=(AI const& other); 17 | ~AI(); 18 | AI* clone() const { return new AI(*this); } 19 | 20 | char const* getAlgorithm() const { return algorithm; } 21 | double getThreshold() const { return threshold; } 22 | 23 | void print(std::ostream& os = std::cout) const; 24 | 25 | void setThreshold(double _threshold) { threshold = _threshold; } 26 | }; 27 | 28 | #endif -------------------------------------------------------------------------------- /practicum/2/10-inheritance-and-templates/solutions/soldier.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | template 5 | class Soldier 6 | { 7 | protected: 8 | char* fName; 9 | unsigned short fAge; 10 | unsigned short fSalary; 11 | T fCombatSkills; 12 | 13 | public: 14 | Soldier(); 15 | Soldier( const char* name, unsigned short age, unsigned short salary, T combatSkills ); 16 | Soldier( const Soldier& other ); 17 | Soldier& operator=( const Soldier& other ); 18 | ~Soldier(); 19 | 20 | protected: 21 | void copy( const Soldier& other ); 22 | void clean(); 23 | 24 | void init( const char* name, unsigned short age, unsigned short salary, T combatSkills ); 25 | 26 | public: 27 | unsigned short getSalary() const; 28 | T getCombatSkills() const; 29 | const char* getName() const; 30 | }; 31 | -------------------------------------------------------------------------------- /practicum/7/Additional-02/Suitcase/ClothingItem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "String.h" 4 | enum class Type { 5 | DRESS, 6 | PANTS, 7 | SUIT 8 | }; 9 | 10 | class ClothingItem { 11 | public: 12 | ClothingItem(const String& color, const String& size, size_t price) { 13 | this->color = color; 14 | this->size = size; 15 | this->price = price; 16 | } 17 | 18 | virtual ~ClothingItem() = default; 19 | 20 | virtual Type getType() const = 0; 21 | 22 | virtual String getColor() const { 23 | return color; 24 | } 25 | 26 | virtual void print(std::ostream& out) const { 27 | out << color << ", " << size << ", " << price; 28 | } 29 | 30 | virtual ClothingItem* clone() = 0; 31 | 32 | private: 33 | String color; 34 | String size; 35 | size_t price; 36 | }; -------------------------------------------------------------------------------- /exercises/4/week07/README.md: -------------------------------------------------------------------------------- 1 | # Read && write 2 | 3 | ## What is streams 4 | ## What are (binary) files 5 | ## read vs cout<< 6 | ## write vs cin>> 7 | ## char* vs reinterpret_cast - https://stackoverflow.com/questions/7831696/reinterpret-cast-vs-c-style-cast 8 | ## Validation !good() eof().... 9 | ## tellg / seekg 10 | 11 | ## Да се дифинира структура(клас) Numbers от числител и знаменател. 12 | ## Да се предефинира стандартен вход и изход за съответната структура. 13 | ## Да се дефинират четене и запит от двоичен файл за колекция от такъв тип структура/клас. 14 | ## Да се отговори на въпроси, колко на брой елемента от този вид има в съответиня файл. 15 | ## Да се намери най-голямото от тях и да се запише във файл maximum.dat 16 | ## Да се сумират всички числа и да се запише във файл sum.dat 17 | -------------------------------------------------------------------------------- /practicum/4/Week10-Inheritance/lab/solution/Drink.cpp: -------------------------------------------------------------------------------- 1 | #include "Drink.h" 2 | 3 | Drink::Drink(std::string_view name, const int quantity, std::string_view description, const double price, const ServingType servingType) 4 | : MenuItem(name, quantity, description, price), m_servingType(servingType) { 5 | } 6 | 7 | std::string Drink::getInfo() const { 8 | std::string info = MenuItem::getInfo(); 9 | 10 | info.replace(0, 9, "Drink"); 11 | 12 | const std::string servingType = m_servingType == ServingType::GLASS ? "Glass" : (m_servingType == ServingType::JUG ? "Jug" : "Bottle"); 13 | 14 | info += "Serving type: " + servingType + '\n'; 15 | 16 | return info; 17 | } 18 | 19 | MenuItem* Drink::clone() const { 20 | return new Drink(m_name, m_quantity, m_description, m_price, m_servingType); 21 | } 22 | -------------------------------------------------------------------------------- /practicum/7/Additional-01/Classwork/Task-2/Order.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "TaxiDriver.h" 3 | 4 | class Order { 5 | public: 6 | Order(); 7 | Order(const char* srcAddr, const char* destAddr, TaxiDriver* driver); 8 | Order(const Order& other); 9 | Order& operator=(const Order& other); 10 | ~Order(); 11 | 12 | const char* getSrcAddr() const { 13 | return srcAddr; 14 | } 15 | 16 | const char* getDestAddr() const { 17 | return destAddr; 18 | } 19 | 20 | friend std::istream& operator>>(std::istream& in, Order& order); 21 | friend std::ostream& operator<<(std::ostream& out, const Order& order); 22 | 23 | private: 24 | void copy(const char* srcAddr, const char* destAddr, TaxiDriver* driver); 25 | void clear(); 26 | 27 | char* srcAddr; 28 | char* destAddr; 29 | TaxiDriver* driver; 30 | }; -------------------------------------------------------------------------------- /exercises/2/PolimorphismAndAbstract/Garage.cpp: -------------------------------------------------------------------------------- 1 | #include "Garage.h" 2 | 3 | void Garage::copy(const Garage& other) 4 | { 5 | size = other.size; 6 | capacity = other.capacity; 7 | cars = new Car * [capacity]; 8 | for (int i = 0; i < size;i++) 9 | { 10 | cars[i] = other.cars[i]->clone(); 11 | } 12 | } 13 | 14 | void Garage::destroy() 15 | { 16 | for (int i = 0; i < size;i++) 17 | { 18 | delete[] cars[i]; 19 | } 20 | delete[] cars; 21 | } 22 | 23 | Garage::Garage() 24 | { 25 | size = 0; 26 | capacity = 5; 27 | cars = new Car * [capacity]; 28 | } 29 | 30 | Garage::~Garage() 31 | { 32 | destroy(); 33 | } 34 | 35 | void Garage::add(Car* addedCar) 36 | { 37 | if (size == capacity) 38 | { 39 | 40 | } 41 | cars[size++] = addedCar->clone(); 42 | } 43 | -------------------------------------------------------------------------------- /practicum/3/10 - 13.05.2022/Ranged.cpp: -------------------------------------------------------------------------------- 1 | #include "Ranged.h" 2 | #include "Weapon.h" 3 | 4 | Ranged::Ranged() { 5 | this->range = 0; 6 | }; 7 | 8 | Ranged::Ranged(int range, char const *name, double damage) : Weapon(name, damage) { 9 | 10 | this->range = range; 11 | }; 12 | 13 | Ranged::Ranged(const Ranged &other) : Weapon(other) { 14 | this->range = other.range; 15 | }; 16 | 17 | Ranged &Ranged::operator=(const Ranged &other) { 18 | 19 | if (this != &other) { 20 | Weapon::operator=(other); 21 | this->range = range; 22 | } 23 | 24 | return *this; 25 | }; 26 | Ranged::~Ranged(){}; 27 | 28 | int Ranged::getRanged() const { 29 | return this->range; 30 | }; 31 | 32 | void Ranged::shoot() { 33 | std::cout << "Ranged weapon shoot " << getName() << std::endl; 34 | } -------------------------------------------------------------------------------- /practicum/7/Week-03-Classes/Theory/5. Delegating constructors.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | class Player { 4 | private: 5 | int health; 6 | int xp; 7 | bool hasUltimate; 8 | public: 9 | Player(); 10 | Player(int healthVal); 11 | Player(int healthVal, int xpVal, bool hasUltimateVal); 12 | }; 13 | 14 | Player::Player(int healthVal, int xpVal, bool hasUltimateVal) : health{ healthVal }, xp{ xpVal }, hasUltimate{hasUltimateVal} { 15 | //... 16 | } 17 | 18 | Player::Player() : Player{ 0,0,0 } { 19 | //... 20 | } 21 | 22 | Player::Player(int healthVal) : Player{ healthVal, 0, 0 } { 23 | //... 24 | } 25 | 26 | 27 | int main() 28 | { 29 | /* 30 | - Code for one constructor can call another in the initialization list 31 | - avoids duplicating code 32 | */ 33 | 34 | 35 | return 0; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /lectures/1/stack/stack.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "stack.hpp" 3 | 4 | // създаване на празен стек 5 | Stack::Stack() { 6 | top = EMPTY_STACK; 7 | } 8 | 9 | // проверка за празнота 10 | bool Stack::empty() const { 11 | return top == EMPTY_STACK; 12 | } 13 | 14 | // включване на елемент 15 | void Stack::push(int const& x) { 16 | assert(!full()); 17 | stack[++top] = x; 18 | } 19 | 20 | // намиране на последния включен елемент 21 | int const& Stack::peek() const { 22 | assert(!empty()); 23 | assert(top >= 0 && top < MAXSTACK); 24 | return stack[top]; 25 | } 26 | 27 | // изключване на последния включен елемент 28 | int Stack::pop() { 29 | assert(!empty()); 30 | return stack[top--]; 31 | } 32 | 33 | bool Stack::full() const { 34 | return top == MAXSTACK - 1; 35 | } -------------------------------------------------------------------------------- /practicum/4/Week06-FriendFunctionsAndGitHub/lab/solutions/Task01/Time.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | enum class Type 6 | { 7 | TWENTY_FOUR, 8 | TWELVE 9 | }; 10 | 11 | class Time 12 | { 13 | unsigned hour; 14 | unsigned minutes; 15 | enum Type type; 16 | bool isAm; 17 | 18 | public: 19 | Time(); 20 | Time(const unsigned hours, const unsigned minutes); 21 | Time(const unsigned hours, const unsigned minutes, const bool isAm); 22 | 23 | Time operator + (const Time& other) const; 24 | Time operator + (const unsigned int hours) const; 25 | friend Time operator + (const unsigned int hours, const Time& second); 26 | 27 | bool operator > (const Time& other) const; 28 | 29 | friend std::ostream& operator << (std::ostream& out, const Time& time); 30 | }; -------------------------------------------------------------------------------- /practicum/3/02 - 04.03.2022/Task 1/main.cpp: -------------------------------------------------------------------------------- 1 | #include "company.hpp" 2 | #include "team.hpp" 3 | #include "worker.hpp" 4 | #include 5 | 6 | int main() { 7 | Worker pesho("pesho", 2, nullptr); 8 | Worker gosho("gosho", 1, &pesho); 9 | Worker stamat("stamat", 0.5, &gosho); 10 | pesho.printCEO(); 11 | gosho.printCEO(); 12 | stamat.printCEO(); 13 | Worker t1e[2] = {pesho, gosho}; 14 | Worker t2e[2] = {gosho, stamat}; 15 | Team t1("t1", t1e, 2); 16 | Team t2("t2", t2e, 2); 17 | 18 | Team te[2] = {t1, t2}; 19 | 20 | Company c("komapniq", te, 2); 21 | std::cout << c.hasEmployee("pesho") << "\n"; 22 | std::cout << c.hasEmployee("gosho") << "\n"; 23 | std::cout << c.hasEmployee("stamat") << "\n"; 24 | std::cout << c.hasEmployee("kiro") << "\n"; 25 | } 26 | -------------------------------------------------------------------------------- /practicum/3/10 - 13.05.2022/Japanka.cpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Japanka.h" 4 | 5 | Japanka::Japanka() : Weapon(), Melee(), Ranged() {} 6 | 7 | Japanka::Japanka(int speed, int range, const char *name, double damage) : Weapon(name, damage), Melee(speed, name, damage), Ranged(range, name, damage) {} 8 | 9 | Japanka::Japanka(const Japanka &other) : Weapon(other), Melee(other), Ranged(other) {} 10 | 11 | Japanka &Japanka::operator=(const Japanka &other) { 12 | Melee::operator=(other); 13 | Ranged::operator=(other); 14 | return *this; 15 | } 16 | Japanka::~Japanka() {} 17 | 18 | void Japanka::attack(const char *target) { 19 | std::cout << "Japanka " << getName() << "attacks target " << target << std::endl; 20 | } 21 | 22 | Weapon *Japanka::clone() const { 23 | return new Japanka(*this); 24 | } -------------------------------------------------------------------------------- /practicum/4/Week10-Inheritance/lab/solution/Food.cpp: -------------------------------------------------------------------------------- 1 | #include "Food.h" 2 | 3 | Food::Food(std::string_view name, const int quantity, std::string_view description, const double price, const bool isBig, const bool isVegan) 4 | : MenuItem(name, quantity, description, price), 5 | isBig(isBig), isVegan(isVegan) { 6 | } 7 | 8 | std::string Food::getInfo() const { 9 | std::string info = MenuItem::getInfo(); 10 | 11 | info.replace(0, 9, "Food"); 12 | 13 | const std::string size = isBig ? "Big" : "Small"; 14 | const std::string vegan = isVegan ? "True" : "False"; 15 | 16 | info += "Size: " + size + '\n'; 17 | info += "Is vegan: " + vegan + '\n'; 18 | 19 | return info; 20 | } 21 | 22 | MenuItem* Food::clone() const { 23 | return new Food(m_name, m_quantity, m_description, m_price, isBig, isVegan); 24 | } 25 | -------------------------------------------------------------------------------- /practicum/7/Additional-01/Classwork/Task-2/TaxiDriver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | class TaxiDriver { 4 | public: 5 | TaxiDriver(); 6 | TaxiDriver(const char* name, size_t salary); 7 | TaxiDriver(const TaxiDriver& other); 8 | TaxiDriver& operator=(const TaxiDriver& other); 9 | ~TaxiDriver(); 10 | 11 | bool isBusy() const { 12 | return busy; 13 | } 14 | 15 | const char* getName() const { 16 | return name; 17 | } 18 | 19 | void setBusy(bool busy) { 20 | this->busy = busy; 21 | } 22 | 23 | friend std::istream& operator>>(std::istream& in, TaxiDriver& driver); 24 | friend std::ostream& operator<<(std::ostream& out, const TaxiDriver& driver); 25 | 26 | private: 27 | void copy(const char* name, size_t salary, bool busy); 28 | 29 | char* name; 30 | size_t salary; 31 | bool busy; 32 | }; -------------------------------------------------------------------------------- /practicum/3/10 - 13.05.2022/Weapon.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | class Weapon { 5 | private: 6 | char *name; 7 | double damage; 8 | void copy(const Weapon &weapon); 9 | void erase(); 10 | 11 | public: 12 | Weapon(); 13 | Weapon(char const *_name, double _damage); 14 | Weapon(Weapon const &weapon); 15 | 16 | virtual ~Weapon(); 17 | 18 | const char *getName() const { 19 | return this->name; 20 | } 21 | void setName(const char *name); 22 | 23 | const double getDamage() const { 24 | return this->damage; 25 | } 26 | void setDamage(double damage); 27 | 28 | virtual void attack(const char *target) = 0; 29 | virtual Weapon *clone() const = 0; 30 | 31 | Weapon &operator=(Weapon const &weapon); 32 | }; 33 | -------------------------------------------------------------------------------- /practicum/4/Week07-Files/lab/solutions/task02.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | const std::size_t MAX_LINE_SIZE = 1024; 5 | 6 | int main (int argc, char** argv) 7 | { 8 | if (argc != 2) 9 | { 10 | std::cout << "Wrong number of arguments" << std::endl; 11 | return 1; 12 | } 13 | 14 | std::ifstream file(argv[1]); 15 | 16 | if (!file.is_open()) 17 | { 18 | std::cout << "Problem while opening the file!" << std::endl; 19 | return 1; 20 | } 21 | 22 | std::size_t counter = 0; 23 | char ch; 24 | while (!file.eof()) 25 | { 26 | file.get(ch); 27 | ++counter; 28 | } 29 | 30 | file.close(); 31 | 32 | std::cout << "The size of the file is " << counter << " bytes" << std::endl; 33 | 34 | return 0; 35 | } -------------------------------------------------------------------------------- /practicum/2/09-templates/solutions/order.cpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "set.cpp" 4 | 5 | template 6 | class Order : public Set { 7 | using Set::items; 8 | using Set::count; 9 | 10 | void sort(); 11 | public: 12 | Order() : Set::Set() {}; 13 | void add(T const &); 14 | }; 15 | 16 | template 17 | void Order::sort() { 18 | for(int i = 0; i < count; i++) { 19 | for(int j = i+1; j < count; j++) { 20 | if(items[i] > items[j]) { 21 | T temp = items[i]; 22 | items[i] = items[j]; 23 | items[j] = temp; 24 | } 25 | } 26 | } 27 | } 28 | 29 | template 30 | void Order::add(T const &temp) { 31 | Set::add(temp); 32 | sort(); 33 | } 34 | -------------------------------------------------------------------------------- /exercises/2/week_2_IntroductionToClasses/Rational.cpp: -------------------------------------------------------------------------------- 1 | #include "Rational.h" 2 | #include 3 | 4 | void Rational::print() const 5 | { 6 | std::cout << this->num << '/' << dem; 7 | } 8 | 9 | void Rational::setNum(int _num) 10 | { 11 | this->num = _num; 12 | } 13 | 14 | void Rational::setDem(int dem) 15 | { 16 | if (dem == 0) 17 | { 18 | std::cout << "0 is not valid"; 19 | return; 20 | } 21 | this->dem = dem; 22 | } 23 | 24 | int Rational::getNum() const 25 | { 26 | return num; 27 | } 28 | 29 | int Rational::getDem() const 30 | { 31 | return dem; 32 | } 33 | 34 | void Rational::read() 35 | { 36 | int n; 37 | std::cout << "Enter num:\n"; 38 | std::cin >> n; 39 | this->setNum(n); 40 | std::cout << "Enter dem\n"; 41 | std::cin >> n; 42 | this->setDem(n); 43 | } 44 | -------------------------------------------------------------------------------- /practicum/2/08-files/solutions/stars/Source.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "Star.h" 4 | 5 | const int MAX_STARS = 64; 6 | const int MAX_FILENAME_LEN = 32; 7 | 8 | int main() 9 | { 10 | Star arr[MAX_STARS]; 11 | 12 | char fileName[MAX_FILENAME_LEN]; 13 | std::cout << "Enter file path: "; 14 | std::cin >> fileName; 15 | 16 | int numOfStars = readStarsFromFile(fileName, arr); 17 | 18 | if (numOfStars == -1) 19 | return -1; 20 | 21 | double closestDistance; // output parameter of getClosestStarIndex 22 | int closestIndex = getClosestStarIndex(arr, numOfStars, closestDistance); 23 | 24 | if (writeResultToFile(fileName, arr[closestIndex], closestDistance)) 25 | std::cout << "Successfully appended result!" << std::endl; 26 | 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /practicum/4/Week10-Inheritance/lab/solution/MenuItem.cpp: -------------------------------------------------------------------------------- 1 | #include "MenuItem.h" 2 | 3 | MenuItem::MenuItem(std::string_view name, const int quantity, std::string_view description, const double price) 4 | : m_name(name), m_quantity(quantity), m_description(description), m_price(price) { 5 | } 6 | 7 | const double MenuItem::getPrice() const { 8 | return m_price; 9 | } 10 | 11 | std::string MenuItem::getInfo() const { 12 | std::string info = "Menu Item:\n"; 13 | 14 | info += "Name: " + m_name + '\n'; 15 | info += "Quantity: " + std::to_string(m_quantity) + '\n'; 16 | info += "Description: " + m_description + '\n'; 17 | info += "Price: " + std::to_string(m_price) + '\n'; 18 | 19 | return info; 20 | } 21 | 22 | MenuItem* MenuItem::clone() const { 23 | return new MenuItem(m_name, m_quantity, m_description, m_price); 24 | } 25 | -------------------------------------------------------------------------------- /practicum/4/Week02-MoreStructs/snippets/02-initializingViaMethod.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | const std::size_t MAX_NAME_SIZE = 50; 5 | 6 | struct Person 7 | { 8 | char name[MAX_NAME_SIZE]; 9 | int age; 10 | double weight; 11 | 12 | void print() 13 | { 14 | std::cout << "My name is " << this->name << ". I am " << this->age << 15 | " years old and I am " << this->weight << " kg." << std::endl; 16 | } 17 | 18 | void initialize(const char* name, int age, double weight) 19 | { 20 | strcpy(this->name, name); 21 | this->age = age; 22 | this->weight = weight; 23 | } 24 | }; 25 | 26 | int main () 27 | { 28 | Person person; 29 | 30 | person.initialize("Stefcho", 20, 77.7); 31 | person.print(); 32 | 33 | return 0; 34 | } -------------------------------------------------------------------------------- /exercises/2/week_11_Inheritance_sample_project/sampleProject/Source.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "CommandsHelper.h" 3 | #include "Students.h" 4 | #include "Program.h" 5 | 6 | int main() { 7 | 8 | Program p; 9 | p.start(); 10 | 11 | char command[32]; 12 | 13 | int commandNumber; 14 | CommandsHelper::printCommands(); 15 | do { 16 | std::cout << "Enter your command: "; 17 | std::cin >> command; 18 | commandNumber = CommandsHelper::getCommand(command); 19 | switch (commandNumber) 20 | { 21 | case ADD: p.executeAdd(); break; 22 | case help: CommandsHelper::printCommands(); break; 23 | case notFound: std::cout << "Command not found, try again\n"; break; 24 | default: break; 25 | } 26 | 27 | } while (commandNumber != exitProgram); 28 | 29 | DBManager::save(); 30 | return 0; 31 | } -------------------------------------------------------------------------------- /practicum/4/Week04-EnumsAndOperatorOveloading/lab/solution/taskManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "task.h" 5 | 6 | const std::size_t INITIAL_CAPACITY = 2; 7 | const std::size_t INCREASE_STEP = 2; 8 | 9 | class TaskManager 10 | { 11 | private: 12 | std::size_t size; 13 | std::size_t capacity; 14 | Task* tasks; 15 | 16 | void copy(const TaskManager& other); 17 | void deallocate(); 18 | void resize(); 19 | 20 | int getIndex(const char* title); 21 | 22 | public: 23 | TaskManager(); 24 | TaskManager(const TaskManager& other); 25 | TaskManager& operator = (const TaskManager& other); 26 | ~TaskManager(); 27 | 28 | std::size_t getTaskCount() const; 29 | void addTask(const Task& task); 30 | void removeTask(const char* title); 31 | const Task& getNextTask() const; 32 | }; -------------------------------------------------------------------------------- /exercises/4/week10/README.md: -------------------------------------------------------------------------------- 1 | ## Inheritance 2 | ### public vs. private vs. protected... 3 | ### constructors and destructors 4 | ### good vs. bad practices 5 | ## virtual - using it out of the box 6 | ## override in C++ - is this good to be used? 7 | ## virtual = 0 = using it out of the box 8 | ### ... and start using objects by pointers... 9 | ## The power of abstract (interface) classes in c++ 10 | ### Multiple Inheritance... 11 | ### Diamond problem and how to resolve it properly... 12 | 13 | 14 | 15 | ## Task... create class animals/mammals... 16 | #### type 17 | #### name 18 | #### weight 19 | #### ... 20 | #### age 21 | 22 | ### Add additional attributes/methods... 23 | ### Create class Dog/Cat/Human 24 | #### ageToHumanAge for each animal 25 | Cat -> age / 9 26 | Dog -> age * 7 27 | Human -> age 28 | ### name 29 | ### poroda 30 | ### sayHello 31 | -------------------------------------------------------------------------------- /practicum/4/Week07-Files/snippets/02-readingFromTextFile/02-04-readingObjects/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "person.h" 4 | 5 | int main () 6 | { 7 | std::ifstream people("people.txt"); 8 | 9 | if (!people.is_open()) // always check if the opening is successfull 10 | { 11 | std::cout << "Problem while opening the file" << std::endl; 12 | return 1; 13 | } 14 | 15 | // Reading the file line by line 16 | 17 | Person tempPerson; 18 | while (!people.eof()) // reading until end of file 19 | { 20 | people >> tempPerson; // only if operator >> is overloaded 21 | // !!! ifstream is a istream (will show this again when we talk about inheritance) 22 | std::cout << tempPerson << std::endl; 23 | } 24 | 25 | people.close(); 26 | 27 | return 0; 28 | } -------------------------------------------------------------------------------- /practicum/4/Week11-AbstractClassesAndPolymorphism/lab/solution/Bed.cpp: -------------------------------------------------------------------------------- 1 | #include "Bed.h" 2 | 3 | Bed::Bed(const double height, const double width, const double length, const int quantity) 4 | : Furniture(height, width, length, quantity) { 5 | m_price = calculatePrice(); 6 | } 7 | 8 | const std::string Bed::getInfo() const { 9 | std::string result = Furniture::getInfo(); 10 | 11 | result.replace(0, 9, "Bed"); 12 | 13 | return result; 14 | } 15 | 16 | const std::string Bed::getStrComparator() const { 17 | return "Bed " + Furniture::getStrComparator(); 18 | } 19 | 20 | Furniture* Bed::clone() { 21 | Furniture* bed = new Bed(m_height, m_width, m_length, m_quantity); 22 | 23 | bed->setID(m_id); 24 | --Furniture::COUNTER; 25 | 26 | return bed; 27 | } 28 | 29 | double Bed::calculatePrice() const { 30 | return m_length * m_height * PRICE_MULTIPLIER; 31 | } 32 | -------------------------------------------------------------------------------- /lectures/1/stack/stack.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __STACK_HPP 2 | #define __STACK_HPP 3 | #include "abstract_stack.hpp" 4 | 5 | class Stack : public AbstractStack { 6 | private: 7 | static const int MAXSTACK = 100; 8 | static const int EMPTY_STACK = -1; 9 | 10 | 11 | // стекът 12 | int stack[MAXSTACK]; 13 | 14 | // индекс на послдния включен елемент 15 | int top; 16 | 17 | // проверка дали стек е запълнен на максимален капацитет 18 | bool full() const; 19 | public: 20 | // създаване на празен стек 21 | Stack(); 22 | 23 | // проверка за празнота 24 | bool empty() const; 25 | 26 | // включване на елемент 27 | void push(int const& x); 28 | 29 | // намиране на последния включен елемент 30 | int const& peek() const; 31 | 32 | // изключване на последния включен елемент 33 | int pop(); 34 | }; 35 | 36 | #endif -------------------------------------------------------------------------------- /practicum/4/Week10-Inheritance/lab/solution/Alcohol.cpp: -------------------------------------------------------------------------------- 1 | #include "Alcohol.h" 2 | 3 | Alcohol::Alcohol(std::string_view name, const int quantity, std::string_view description, const double price, const ServingType servingType, const double alcoholPercentage) 4 | : Drink(name, quantity, description, price, servingType), m_alcoholPercentage(alcoholPercentage) { 5 | } 6 | 7 | const double Alcohol::getAlcoholPercentage() const { 8 | return m_alcoholPercentage; 9 | } 10 | 11 | std::string Alcohol::getInfo() const { 12 | std::string info = Drink::getInfo(); 13 | 14 | info.replace(0, 5, "Alcohol"); 15 | 16 | info += "Alcohol Percentage: " + std::to_string(m_alcoholPercentage) + '\n'; 17 | 18 | return info; 19 | } 20 | 21 | MenuItem* Alcohol::clone() const { 22 | return new Alcohol(m_name, m_quantity, m_description, m_price, m_servingType, m_alcoholPercentage); 23 | } 24 | -------------------------------------------------------------------------------- /exercises/4/week12/README.md: -------------------------------------------------------------------------------- 1 | # Функции от по-висок ред ... и имат ли почва у нас... 2 | ## Разглеждаме структура 3 | Book { 4 | string author; 5 | string name; 6 | int year; 7 | int pages; 8 | double raiting; 9 | } 10 | 11 | ### Да се реализира сортиране по рейтинг на книгите ASC 12 | ### Да се реализира сортиране по година на издаване на книгите ASC 13 | ### Да се върне списък (vector) от книгите, които са на съответен автор. 14 | ### Да се върне списък (vector) от книгите, които са издадени от автор над определен брой страници. 15 | ### Реализирайте map/filter за масив/vector 16 | ### Какво е lambda и кога/защо да го ползваме? 17 | 18 | SOLID 19 | 20 | ## S - Single-responsiblity Principle 21 | ## O - Open-closed Principle 22 | ## L - Liskov Substitution Principle 23 | ## I - Interface Segregation Principle 24 | ## D - Dependency Inversion Principle 25 | 26 | Examples.... 27 | -------------------------------------------------------------------------------- /practicum/4/Week14-UnitTests/snippets/01-OurFirstUniTests/tests.cpp: -------------------------------------------------------------------------------- 1 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 2 | #include "../doctest.h" 3 | #include "calculator.h" 4 | 5 | TEST_CASE("test addition") 6 | { 7 | Calculator calculator; 8 | 9 | REQUIRE(calculator.sum(5, 6) == 11); 10 | REQUIRE_EQ(calculator.sum(4, 8), 12); 11 | } 12 | 13 | TEST_CASE("test multiplication") 14 | { 15 | Calculator calculator; 16 | 17 | //CHECK(calculator.multiply(2.356, 3.876) == 9.131856); 18 | REQUIRE(calculator.multiply(2.356, 3.876) == doctest::Approx(9.131856)); 19 | } 20 | 21 | TEST_CASE("test division") 22 | { 23 | Calculator calculator; 24 | 25 | REQUIRE(calculator.divide(5,2) == doctest::Approx(2.5)); 26 | REQUIRE_THROWS(calculator.divide(10, 0)); 27 | REQUIRE_THROWS_AS(calculator.divide(15, 0), std::invalid_argument); 28 | REQUIRE_NOTHROW(calculator.divide(5,2)); 29 | } -------------------------------------------------------------------------------- /practicum/3/06, 07 - 08.04.2022/README.md: -------------------------------------------------------------------------------- 1 | # Задачи за ООП практикум на 3та група - 08.04.2022 2 | 3 | ## Задача 1 4 | * Да се дефинира клас `DateTime` с подходящи методи и оператори. 5 | * Да се дефинира клас `Event` с подходящи методи и оператори. Всяко събитие има име, начална дата и час и крайна дата и час. 6 | * Да се дефинира клас `Schedule` с подходящи методи и оператори. Всяка програма има име и масив от събития. 7 | 8 | ## Задача 2 9 | _**Решението тук е недовършено, продължаваме следващия път**_ 10 | 11 | За всеки от класовете да се реализира сериализация и десериализация (както бинарна, така и текстова). 12 | 13 | ## Задача 3 (домашно) 14 | Реализирайте подходящи оператори, сериализация и десериализация за [**комплексното число**](https://github.com/triffon/oop-2021-22/tree/main/practicum/3/02%20-%2004.03.2022#%D0%B7%D0%B0%D0%B4%D0%B0%D1%87%D0%B0-2-%D0%B4%D0%BE%D0%BC%D0%B0%D1%88%D0%BD%D0%BE). 15 | -------------------------------------------------------------------------------- /practicum/2/05-overloading-operators/solutions/Virus.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | class Virus 5 | { 6 | public: 7 | Virus(const char* name = "", double severity = 0); 8 | Virus(const Virus& other); 9 | Virus& operator=(const Virus& other); 10 | ~Virus(); 11 | 12 | bool operator<(const Virus& other) const; 13 | bool operator>=(const Virus& other) const; 14 | bool operator>(const Virus& other) const; 15 | bool operator<=(const Virus& other) const; 16 | 17 | const char* getName() const { return name; } 18 | void setName(const char* newName); 19 | double getSeverity() const { return severity; } 20 | void setSeverity(double newSeverity); 21 | 22 | private: 23 | 24 | void copy(const Virus& other); 25 | void clear(); 26 | 27 | double severity; 28 | char* name; 29 | }; 30 | 31 | std::ostream& operator<<(std::ostream& out, const Virus& obj); 32 | -------------------------------------------------------------------------------- /practicum/4/Week04-EnumsAndOperatorOveloading/snippets/02-enums/book.cpp: -------------------------------------------------------------------------------- 1 | #include "book.h" 2 | #include 3 | #include 4 | #include 5 | 6 | Book::Book() 7 | { 8 | strcpy(this->name, ""); 9 | this->yearOfPublication = 0; 10 | } 11 | 12 | Book::Book(const char* name, const int yearOfPublication, BookType type) 13 | { 14 | assert(name != nullptr); 15 | 16 | strcpy(this->name, name); 17 | this->yearOfPublication = yearOfPublication; 18 | this->type = type; 19 | } 20 | 21 | const char* Book::getName() const 22 | { 23 | return this->name; 24 | } 25 | 26 | BookType Book::getType() const 27 | { 28 | return this->type; 29 | 30 | } 31 | 32 | void Book::setType(BookType type) 33 | { 34 | this->type = type; 35 | } 36 | 37 | void Book::print() 38 | { 39 | assert(this->name != nullptr); 40 | 41 | std::cout << this->name << ", " << this->yearOfPublication << std::endl; 42 | } -------------------------------------------------------------------------------- /practicum/4/Week12-MultiInheritance/snippets/04-multiInheritance.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | class Flyable 4 | { 5 | public: 6 | Flyable() 7 | { 8 | std::cout << "I can fly" << std::endl; 9 | } 10 | 11 | virtual ~Flyable() 12 | { 13 | std::cout << "Bye, bye, flyable" << std::endl; 14 | } 15 | }; 16 | 17 | class Mammal 18 | { 19 | public: 20 | Mammal() 21 | { 22 | std::cout << "I am mammal" << std::endl; 23 | } 24 | 25 | virtual ~Mammal() 26 | { 27 | std::cout << "Bye, bye, mammal" << std::endl; 28 | } 29 | }; 30 | 31 | class Bat : public Mammal, public Flyable 32 | { 33 | public: 34 | Bat() 35 | { 36 | std::cout << "I am a bat" << std::endl; 37 | } 38 | 39 | ~Bat() 40 | { 41 | std::cout << "Bat destroyed" << std::endl; 42 | } 43 | }; 44 | 45 | int main () 46 | { 47 | Bat b; 48 | 49 | return 0; 50 | } -------------------------------------------------------------------------------- /exercises/2/PreparationForTest_2/Relation.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | template 4 | class Relation { 5 | private: 6 | T subject, object; 7 | char* action; 8 | public: 9 | Relation(T s, T o, const char* a) : subject(s), object(o) { 10 | action = new char[strlen(a) + 1]; 11 | strcpy_s(action, strlen(a) + 1, a); 12 | } 13 | //Relation(const Relation& other); 14 | //Relation& operator =(const Relation& other); 15 | //~Relation(); 16 | void print() const { 17 | std::cout << subject << ' ' << action << ' ' << object; 18 | } 19 | Relation operator *(const Relation& other) { 20 | if (object != other.subject) { 21 | return Relation(*this); 22 | } 23 | char* res = new char[strlen(action) + 1 + strlen(", which is ") + strlen(other.action)]; 24 | //strcpy strcat 25 | Relation result(this->subject, other.object, res); 26 | delete[] res; 27 | return result; 28 | } 29 | }; -------------------------------------------------------------------------------- /exercises/2/week_5_tasks/Source.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "ServerFarm.h" 3 | #include "WebServer.h"; 4 | #include "SumAvgCalculator.h" 5 | 6 | int main() { 7 | //WebServer server, server2; 8 | //server.read(); 9 | //server2.read(); 10 | //server.print(); 11 | //server2.print(); 12 | //std::cout << (server < server2); 13 | //std::cout << (server == server2); 14 | 15 | //ServerFarm farm; 16 | //farm.addServer(server); 17 | //farm.addServer(server); 18 | //farm.addServer(server); 19 | //farm.addServer(server2).addServer(server).sort().print(); 20 | 21 | SumAvgCalculator c(10), p(5), k(3); 22 | c.add(10); 23 | c.add(5); 24 | c.sub(15); 25 | 26 | std::cout << c.sum() << " " << c.avarage() << '\n'; 27 | 28 | p = c + k; 29 | std::cout << p.sum() << " " << p.avarage() << '\n'; 30 | 31 | p += c; 32 | std::cout << p.sum() << " " << p.avarage() << '\n'; 33 | 34 | return 0; 35 | } -------------------------------------------------------------------------------- /lectures/1/player/ai.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "ai.hpp" 3 | 4 | AI::AI(char const* _algorithm, double _threshold) : algorithm(nullptr), threshold(_threshold) { 5 | setAlgorithm(_algorithm); 6 | } 7 | 8 | void AI::setAlgorithm(char const* _algorithm) { 9 | delete[] algorithm; 10 | algorithm = new char[strlen(_algorithm) + 1]; 11 | strcpy(algorithm, _algorithm); 12 | } 13 | 14 | AI::AI(AI const& other) : algorithm(nullptr), threshold(other.threshold) { 15 | setAlgorithm(other.algorithm); 16 | } 17 | 18 | AI& AI::operator=(AI const& other) { 19 | if (this != &other) { 20 | setAlgorithm(other.algorithm); 21 | threshold = other.threshold; 22 | } 23 | return *this; 24 | } 25 | 26 | AI::~AI() { 27 | delete[] algorithm; 28 | } 29 | 30 | void AI::print(std::ostream& os) const { 31 | os << "изкуствен интелект с алгоритъм " << getAlgorithm() << " и праг " << getThreshold(); 32 | } 33 | -------------------------------------------------------------------------------- /practicum/7/Week-12-Polymorphism/Task-1/ShapeContainer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Shape.h" 3 | class ShapeContainer { 4 | public: 5 | ShapeContainer() { 6 | arr = new Shape* [10]; 7 | size = 0; 8 | } 9 | 10 | //copy 11 | //operator= 12 | 13 | ~ShapeContainer() { 14 | delete[] arr; 15 | } 16 | 17 | void addShape(Shape* shape) { 18 | if (size >= 10) return; 19 | 20 | arr[size] = shape; 21 | size++; 22 | } 23 | 24 | void print() const { 25 | for (size_t i = 0; i < size; ++i) 26 | arr[i]->print(); 27 | } 28 | 29 | void printPerimeters() const { 30 | for (size_t i = 0; i < size; ++i) { 31 | std::cout << arr[i]->perimeter() << " "; 32 | } 33 | std::cout << "\n\n"; 34 | } 35 | 36 | void printSurfaces() const { 37 | for (size_t i = 0; i < size; ++i) { 38 | std::cout << arr[i]->surface() << " "; 39 | } 40 | std::cout << "\n\n"; 41 | } 42 | 43 | private: 44 | Shape** arr; 45 | size_t size; 46 | }; -------------------------------------------------------------------------------- /practicum/3/06, 07 - 08.04.2022/Task 1 & Task 2/Schedule.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __SCHEDULE_HPP__ 2 | #define __SCHEDULE_HPP__ 3 | 4 | #include "Event.hpp" 5 | 6 | #include 7 | 8 | class Schedule { 9 | char *name; 10 | Event *events; 11 | size_t eventsCapacity; 12 | size_t eventsSize; 13 | 14 | void copyEvents(const Event *events, size_t eventSize); 15 | 16 | public: 17 | Schedule(); 18 | Schedule(const char *name, const Event *events, size_t eventSize); 19 | Schedule(const Schedule &o); 20 | ~Schedule(); 21 | 22 | const char *getName() const; 23 | void setName(const char *name); 24 | 25 | size_t getEventsSize() const; 26 | 27 | Event *getEvents(); 28 | void addEvent(const Event &e); 29 | void removeLastEvent(); 30 | 31 | Schedule &operator=(const Schedule &o); 32 | 33 | friend std::ostream &operator<<(std::ostream &out, const Schedule &d); 34 | }; 35 | 36 | #endif // __SCHEDULE_HPP__ -------------------------------------------------------------------------------- /practicum/3/11, 12 - 19 & 20.05.2022/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "Array.hpp" 4 | 5 | template 6 | T add1(const T &num) { 7 | return num + 1; 8 | } 9 | 10 | template 11 | T print(const T &num) { 12 | std::cout << num << " "; 13 | return num; 14 | } 15 | 16 | template 17 | bool even(const T &num) { 18 | return num % 2 == 0; 19 | } 20 | 21 | int main() { 22 | Array asd; 23 | asd.add(1); 24 | asd.add(2); 25 | asd.add(3); 26 | asd.add(4); 27 | asd.add(5); 28 | asd.map(add1); 29 | Array asd1 = asd.filter(even); 30 | asd1.map(print); 31 | try { 32 | asd[100]; 33 | } catch (OutOfRange e) { 34 | std::cout << "OutOfRange\n"; 35 | std::cout << e.what() << std::endl; 36 | } catch (std::out_of_range e) { 37 | std::cout << "std::out_of_range\n"; 38 | std::cout << e.what() << std::endl; 39 | } 40 | } -------------------------------------------------------------------------------- /exercises/2/PolimorphismAndAbstract/Source.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Expressions.h" 3 | 4 | double maxAll(Expression** arr, int n) 5 | { 6 | double max = 0.0; 7 | for (int i = 0; i < n;i++) 8 | { 9 | double currrent = arr[i]->value(); 10 | if (currrent > max) 11 | { 12 | max = currrent; 13 | } 14 | } 15 | return max; 16 | } 17 | 18 | int main() { 19 | Expression* ptr; 20 | Expression* ptr2; 21 | Expression* ptr3; 22 | Expression* ptr4; 23 | Expression* ptr5; 24 | Constant c(5.5); 25 | Constant a(4.5); 26 | Constant s(3.5); 27 | Constant d(7.5); 28 | Constant f(0.5); 29 | ptr = &c; 30 | ptr2 = &a; 31 | ptr3 = &s; 32 | ptr4 = &d; 33 | ptr5 = &f; 34 | 35 | Expression** arr = new Expression * [5]; 36 | arr[0] = ptr; 37 | arr[1] = ptr2; 38 | arr[2] = ptr3; 39 | arr[3] = ptr4; 40 | arr[4] = ptr5; 41 | 42 | std::cout << maxAll(arr, 5); 43 | delete[] arr; 44 | return 0; 45 | } -------------------------------------------------------------------------------- /practicum/7/Week-10-Inheritance/Solutions/Task1/Animal.cpp: -------------------------------------------------------------------------------- 1 | #include "Animal.h" 2 | #include 3 | #include 4 | 5 | Animal::Animal():name(nullptr), age(0) { 6 | setName("Default Animal"); 7 | } 8 | 9 | Animal::Animal(const char* name, unsigned age): name(nullptr) { 10 | setName(name); 11 | this->age = age; 12 | } 13 | 14 | Animal::Animal(const Animal& other) { 15 | setName(other.name); 16 | age = other.age; 17 | } 18 | Animal& Animal::operator=(const Animal& other) { 19 | if (this != &other) { 20 | setName(other.name); 21 | age = other.age; 22 | } 23 | 24 | return *this; 25 | } 26 | 27 | Animal::~Animal() { 28 | delete[] name; 29 | } 30 | 31 | void Animal::print() const { 32 | std::cout << name << ", " << age << std::endl; 33 | } 34 | void Animal::setName(const char* name) { 35 | if (this->name) 36 | delete[] this->name; 37 | 38 | this->name = new char[strlen(name) + 1]; 39 | strcpy_s(this->name, strlen(name) + 1, name); 40 | } -------------------------------------------------------------------------------- /practicum/4/Week09-StaticAndTemplates/snippets/03-singleton.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | class Singleton 4 | { 5 | private: 6 | static int counter; 7 | int id; 8 | 9 | Singleton() 10 | { 11 | this->id = counter++; 12 | } 13 | public: 14 | Singleton(const Singleton& other) = delete; 15 | Singleton& operator = (const Singleton& other) = delete; 16 | 17 | static Singleton& getInstance() 18 | { 19 | static Singleton object; 20 | 21 | return object; 22 | } 23 | 24 | void whoAmI() const 25 | { 26 | std::cout << "I am instance #" << this->id << std::endl; 27 | } 28 | }; 29 | 30 | int Singleton::counter = 0; 31 | 32 | int main () 33 | { 34 | Singleton::getInstance().whoAmI(); 35 | Singleton::getInstance().whoAmI(); 36 | Singleton::getInstance().whoAmI(); 37 | Singleton::getInstance().whoAmI(); 38 | Singleton::getInstance().whoAmI(); 39 | 40 | return 0; 41 | } -------------------------------------------------------------------------------- /practicum/7/Additional-02/Suitcase/main.cpp: -------------------------------------------------------------------------------- 1 | #include "Suitcase.h" 2 | #include "ClothingItem.h" 3 | #include "Dress.h" 4 | #include "Pants.h" 5 | #include "Suit.h" 6 | #include "Person.h" 7 | 8 | int main() { 9 | Person pesho("Pesho", "Sofia, James Boucher, 105", "+35965273663"); 10 | 11 | Suitcase s("bembeno", &pesho); 12 | 13 | Dress dress("red", "M", 105, 95); 14 | Pants pants("black", "L", 50, 100); 15 | Suit suit("yellow", "XL", 86); 16 | 17 | s.addClothing(&dress); 18 | s.addClothing(&pants); 19 | s.addClothing(&suit); 20 | 21 | s.print(std::cout); 22 | 23 | std::cout << std::boolalpha << s.isInsideColor("red") << "\n"; 24 | std::cout << std::boolalpha << s.isInsideType(Type::PANTS) << "\n"; 25 | std::cout << std::boolalpha << s.isInsideTypeColor(Type::PANTS, "red") << "\n"; 26 | 27 | ClothingItem* removed = s.removeClothing(2); 28 | if (removed) 29 | removed->print(std::cout); 30 | 31 | s.print(std::cout); 32 | 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /lectures/1/files/product.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __PRODUCT_HPP 2 | #define __PRODUCT_HPP 3 | 4 | #include 5 | 6 | const size_t MAX_NAME = 100; 7 | const unsigned INITIAL_ID = 100; 8 | 9 | class Product { 10 | unsigned id; 11 | char name[MAX_NAME]; 12 | float price; 13 | 14 | public: 15 | Product(unsigned _id = 0, char const* _name = "неизвестен", float _price = 1.0); 16 | 17 | unsigned getId() const { return id; } 18 | char const* getName() const { return name; } 19 | float getPrice() const { return price; } 20 | 21 | void applyDiscount(float discount); 22 | 23 | // форматиран вход 24 | friend std::istream& operator>>(std::istream& is, Product&); 25 | 26 | // неформатиран вход 27 | void read(std::fstream& ifs, unsigned _id); 28 | 29 | // неформатиран изход 30 | void write(std::fstream& ofs) const; 31 | }; 32 | 33 | // форматиран изход 34 | std::ostream& operator<<(std::ostream& os, Product const&); 35 | 36 | #endif -------------------------------------------------------------------------------- /practicum/4/Week12-MultiInheritance/lab/README.md: -------------------------------------------------------------------------------- 1 | # Полиморфично клониране и множествено наследяване 2 | 3 | ## Задача 1 :mirror: 4 | Реализирайте полиморфично клониране за класовете, които съдържат масиви от пойнтъри, сочещи към различен тип обекти, (хетерогенни контейнери) от предишните два практикума - `Menu` (Week10) и `FurnitureHouse` (Week11) 5 | 6 | ## Задача 2 :man_student::man_teacher: 7 | Да се напишат следните класове: 8 | - `Person` - съдържа име 9 | - `Student` - наследява `Person` и добавя поле за факултетен номер 10 | - `Teacher` - наследява `Person` и добавя поле за заплата 11 | - `Assistant` - наследява `Student` и `Teacher` 12 | 13 | Напишете селектори за всички член-данни, като помислите къде е най-удачно да стои всеки един от тях. 14 | 15 | Да се демонстрира така създадената йерархия, като се създаде обект от тип `Assistant` и се попълнят всички полета. 16 | 17 | Да се извикат методите `getName()`, `getFN()`, `getSalary()` и да се принтират в конзолата. -------------------------------------------------------------------------------- /lectures/1/player/player.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __PLAYER_HPP 2 | #define __PLAYER_HPP 3 | 4 | #include 5 | #include "printable.hpp" 6 | 7 | const int MAXNAME = 100; 8 | 9 | class Player : virtual public Printable { 10 | //char name[MAXNAME]; 11 | char* name; 12 | 13 | static unsigned playerCount; 14 | 15 | protected: 16 | unsigned score; 17 | 18 | void addPoints(unsigned points) { score += points; } 19 | 20 | public: 21 | 22 | Player(const char* _name = "<анонимен>", unsigned _score = 0); 23 | Player(Player const&); 24 | Player& operator=(Player const&); 25 | ~Player(); 26 | Printable* clone() const { return new Player(*this); } 27 | 28 | char const* getName() const { return name; } 29 | unsigned getScore() const { return score; } 30 | 31 | void setName(char const* _name); 32 | 33 | virtual void print(std::ostream& os = std::cout) const; 34 | 35 | static unsigned getPlayerCount();// { return playerCount; } 36 | }; 37 | 38 | #endif -------------------------------------------------------------------------------- /practicum/7/Week-06-Operator-Overloading/Theory & Examples/main.cpp: -------------------------------------------------------------------------------- 1 | #include "IntArr.h" 2 | #include 3 | 4 | int main() { 5 | 6 | IntArr arr1; 7 | IntArr arr2 = arr1 + 5 + 10 + 3; 8 | 9 | std::cout << "arr2: \n"; 10 | arr2.print(); 11 | 12 | std::cout << "\narr1: \n"; 13 | arr1.print(); 14 | 15 | std::cout << "\nIs arr1 empty: " << std::boolalpha << !arr1 16 | << "\nIs arr2 empty: " << std::boolalpha << !arr2 << std::endl; 17 | 18 | arr1 += 2; 19 | arr1 += 4; 20 | 21 | std::cout << "\narr1: \n"; 22 | arr1.print(); 23 | 24 | std::cout << "\nIs arr2 bigger than arr1: " << std::boolalpha << (arr2 > arr1) << std::endl; 25 | 26 | std::cout << "\narr1++: \n"; 27 | (arr1++); 28 | arr1.print(); 29 | 30 | IntArr arr3 = arr1 + arr2; 31 | 32 | std::cout << "\narr3: \n"; 33 | arr3.print(); 34 | 35 | arr3 *= 2; 36 | std::cout << "\nDoubled arr3: \n"; 37 | arr3.print(); 38 | 39 | std::cout << "\nElement 3 of arr3: \n" << arr3[3] << std::endl; 40 | 41 | return 0; 42 | } -------------------------------------------------------------------------------- /exercises/7/Week-1/README.md: -------------------------------------------------------------------------------- 1 | # Assignment 2 | 3 | ## Prerequisites 4 | - [Install C++ Compiler](https://code.visualstudio.com/docs/languages/cpp#_install-a-compiler) 5 | - [Install VSCode](https://code.visualstudio.com/download) 6 | - [Install VSCode C++ Extension](https://code.visualstudio.com/docs/languages/cpp#_install-the-extension) 7 | 8 | ## Recap from Lectures 9 | - [Data Structures in C++](https://www.cplusplus.com/doc/tutorial/structures/) 10 | - [Data Abstraction in C++](https://www.tutorialspoint.com/cplusplus/cpp_data_abstraction.htm) 11 | 12 | ## Problems 13 | - Write a C++ struct that represents a fraction. Provide capabilities for addition, substraction, division and multiplication (see: [example](https://github.com/triffon/oop-2021-22/blob/master/exercises/7/Week-1/Examples/FractionExample.cpp)). 14 | 15 | ## Solutions 16 | Upload solutions in your GitHub folder (see: [how-to](https://www.atlassian.com/git/tutorials/saving-changes/git-commit)) (only .CPP files, no executable files) 17 | -------------------------------------------------------------------------------- /practicum/4/Week01-Structs/snippets/01-structCreation.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | const std::size_t MAX_NAME_SIZE = 50; 5 | 6 | struct Person 7 | { 8 | char name[MAX_NAME_SIZE]; 9 | int age; 10 | double weight; 11 | }; 12 | 13 | void printPerson(const Person& person) 14 | { 15 | std::cout << "My name is " << person.name << ". I am " << person.age << 16 | " years old and I am " << person.weight << " kg." << std::endl; 17 | } 18 | 19 | int main () 20 | { 21 | Person basicPerson; // struct creation with undefined fields 22 | 23 | // field initialization (access operator '.') 24 | strcpy(basicPerson.name, "Gosho"); 25 | basicPerson.age = 18; 26 | basicPerson.weight = 78.4; 27 | 28 | // printing information about the person 29 | printPerson(basicPerson); 30 | 31 | Person directInitPerson{"Ivan", 19, 67.8}; // struct creation with direct initialization 32 | printPerson(directInitPerson); 33 | 34 | return 0; 35 | } -------------------------------------------------------------------------------- /exercises/2/week_5_tasks/SumAvgCalculator.cpp: -------------------------------------------------------------------------------- 1 | #include "SumAvgCalculator.h" 2 | 3 | SumAvgCalculator::SumAvgCalculator(int initialValue) 4 | { 5 | totalSum = initialValue; 6 | size = 1; 7 | } 8 | 9 | int SumAvgCalculator::sum() const 10 | { 11 | return totalSum; 12 | } 13 | 14 | void SumAvgCalculator::add(unsigned number) 15 | { 16 | totalSum += number; 17 | size++; 18 | } 19 | 20 | void SumAvgCalculator::sub(int number) 21 | { 22 | totalSum += (-1 *number); 23 | size++; 24 | } 25 | 26 | double SumAvgCalculator::avarage() const 27 | { 28 | return ((double)totalSum/(double)size); 29 | } 30 | 31 | SumAvgCalculator SumAvgCalculator::operator+(const SumAvgCalculator& other) 32 | { 33 | SumAvgCalculator result(this->totalSum + other.totalSum); 34 | result.size = this->size + other.size; 35 | return result; 36 | } 37 | 38 | SumAvgCalculator& SumAvgCalculator::operator+=(const SumAvgCalculator& other) 39 | { 40 | *this = *this + other; 41 | return *this; 42 | } 43 | -------------------------------------------------------------------------------- /exercises/1/exercises/07-files/files.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using std::ios; 6 | 7 | /* 8 | a -> A 9 | A -> a 10 | 1 -> 1 11 | */ 12 | 13 | const int letter_diff{'a' - 'A'}; 14 | 15 | 16 | char change_letter_capitalization(char c) 17 | { 18 | if ( c >= 'a' && c <= 'z') 19 | { 20 | return c - letter_diff; 21 | } 22 | 23 | if (c >= 'A' && c <= 'Z') 24 | { 25 | return c + letter_diff; 26 | } 27 | 28 | return c; 29 | } 30 | 31 | void change_capitalization(std::fstream& file) 32 | { 33 | char c{}; 34 | while (file) 35 | { 36 | file.get(c); 37 | file.seekg(-1, std::ios::cur); 38 | file.put(change_letter_capitalization(c)); 39 | } 40 | } 41 | 42 | int main() 43 | { 44 | std::fstream file{ 45 | "file.txt", 46 | ios::in | ios::out 47 | }; 48 | 49 | change_capitalization(file); 50 | 51 | // Duma 2ra Duma malka duma GOLQMA DUMA 52 | 53 | return 0; 54 | } -------------------------------------------------------------------------------- /practicum/2/10-inheritance-and-templates/solutions/commander.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Soldier.h" 4 | 5 | template 6 | class Commander : public Soldier 7 | { 8 | Soldier* fSquad; 9 | size_t fSize; 10 | size_t fCapacity; 11 | char* fDescription; 12 | 13 | public: 14 | Commander(); 15 | Commander( const char* name, unsigned short age, unsigned short salary, T combatSkills, 16 | const char* desc, size_t fCapacity = 16 ); 17 | Commander( const Soldier& soldier, const char* desc, size_t fCapacity = 16 ); 18 | Commander( const Commander& other ); 19 | Commander& operator=( const Commander& other ); 20 | ~Commander(); 21 | 22 | 23 | private: 24 | void copy( const Commander& other ); 25 | void clean(); 26 | void init( const char* desc, size_t fCapacity ); 27 | bool resize(); 28 | 29 | public: 30 | bool addSoldier( const Soldier& soldier ); 31 | unsigned int getSquadSalary() const; 32 | unsigned int getSquadSize() const; 33 | T getSquadCombatSkills() const; 34 | 35 | }; 36 | -------------------------------------------------------------------------------- /exercises/1/bonuses/bitmaps/thumbnail.md: -------------------------------------------------------------------------------- 1 | # Creating Thumbnails 2 | 3 | ## Problem 4 | 5 | ```c++ 6 | void create_thumbnail(const char * original_name, const char * thumbnail_name, 7 | uint32_t x, uint32_t y, uint32_t width, uint32_t height) 8 | ``` 9 | 10 | Create a new .bmp file (same format as grayscale problem) with the given thumbnail_name by copying a rectangle from the other .bmp file (original_name) with lower left corner at coordinates (x; y) and the given dimensions (each side is parallel to one of the axes) 11 | 12 | ## Notes 13 | 14 | - Carefully copy the metadata and alter what you need 15 | - Note the order of the lines 16 | - You don't have to check for I/O or format errors, assume everything goes right 17 | 18 | ## Example 19 | 20 | ```c++ 21 | create_thumbnail("monkas.bmp", "140-300-200-180-example.bmp", 140, 300, 200, 180); 22 | ``` 23 | 24 | ![monkas](monkas.bmp?raw=true "monkas.bmp") 25 | 26 | ![140-300-200-180-example](140-300-200-180-example.bmp?raw=true "140-300-200-180-example.bmp") -------------------------------------------------------------------------------- /exercises/2/week_8_file_read_write+binary/ServerFarm.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "WebServer.h" 3 | #include 4 | #include 5 | 6 | class ServerFarm { 7 | private: 8 | WebServer* farm; 9 | unsigned size; 10 | unsigned capacity; 11 | char* name; 12 | void copy(const ServerFarm& other); 13 | void destroy(); 14 | void resize(); 15 | public: 16 | ServerFarm(); 17 | ServerFarm(int capacity); 18 | ServerFarm(const char* _name); 19 | ServerFarm(const ServerFarm& other); 20 | ServerFarm& operator =(const ServerFarm& other); 21 | ~ServerFarm(); 22 | ServerFarm& addServer(const WebServer newServer); 23 | void print() const; 24 | ServerFarm& operator -=(int* address); 25 | int countInNetwork(int address) const; 26 | void findMaxNetwork() const; 27 | ServerFarm& sort(); 28 | 29 | //exercise 30 | void save(const char* fileName); 31 | void read(const char* fileName); 32 | //binary 33 | void saveBin(const char* fileName); 34 | void readBin(const char* fileName); 35 | 36 | }; -------------------------------------------------------------------------------- /practicum/2/08-files/solutions/stars/Star.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | struct Star { 5 | double x; 6 | double y; 7 | double z; 8 | }; 9 | 10 | // Reads Star obj from filestream in 11 | void readStarFromFile(std::ifstream& in, Star& obj); 12 | 13 | // Reads the whole file with name fileName and 14 | // loads all the stars in the given array 15 | // Returns the number of read stars 16 | // or -1 if the function failed 17 | int readStarsFromFile(const char* fileName, Star* arr); 18 | 19 | // Returns the index of the closest star from the array 20 | // closestDistance is an output parameter 21 | int getClosestStarIndex(const Star* arr, int size, double& closestDistance); 22 | 23 | // Returns the distance from the center to the given star 24 | double distance(const Star& star); 25 | 26 | // Writes the output message with the given star and distance to the file 27 | // Returns true if the function was executed successfully 28 | bool writeResultToFile(const char* fileName, const Star& star, double dist); 29 | -------------------------------------------------------------------------------- /practicum/4/Week04-EnumsAndOperatorOveloading/lab/solution/task.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "taskCategory.h" 4 | #include "date.h" 5 | 6 | const std::size_t MAX_TITLE_SIZE = 50; 7 | const std::size_t MAX_DESCRIPTION_SIZE = 500; 8 | 9 | class Task 10 | { 11 | private: 12 | char title[MAX_TITLE_SIZE]; 13 | char description[MAX_DESCRIPTION_SIZE]; 14 | TaskCategory category; 15 | Date deadline; 16 | 17 | public: 18 | Task(); 19 | Task(const char* title, const char* description, 20 | const TaskCategory category, const Date deadline); 21 | 22 | const char* getTitle() const; 23 | const char* getDescription() const; 24 | TaskCategory getCategory() const; 25 | Date getDeadline() const; 26 | 27 | void setTitle(const char* title); 28 | void setDescription(const char* description); 29 | void setCategory(const TaskCategory category); 30 | void setDeadline(const Date deadline); 31 | 32 | bool operator < (const Task& other) const; 33 | 34 | void print() const; 35 | }; -------------------------------------------------------------------------------- /practicum/4/Week11-AbstractClassesAndPolymorphism/lab/solution/FurnitureHouse.h: -------------------------------------------------------------------------------- 1 | #ifndef FURNITUREHOUSE_H 2 | #define FURNITUREHOUSE_H 3 | 4 | #include "Furniture.h" 5 | 6 | class FurnitureHouse { 7 | public: 8 | FurnitureHouse(); 9 | FurnitureHouse(const FurnitureHouse& other); 10 | ~FurnitureHouse(); 11 | 12 | size_t size() const; 13 | 14 | Furniture* getFurnitureAtID(const int id) const; 15 | 16 | void print() const; 17 | 18 | Furniture* operator[](const int index); 19 | const Furniture* operator[](const int index) const; 20 | 21 | FurnitureHouse& operator+=(Furniture* furniture); 22 | FurnitureHouse& operator-=(Furniture* furniture); 23 | 24 | FurnitureHouse& operator=(const FurnitureHouse& other); 25 | 26 | private: 27 | Furniture** m_data; 28 | size_t m_size; 29 | size_t m_capacity; 30 | 31 | void deleteData(); 32 | void allocData(size_t newCapacity); 33 | void copy(const FurnitureHouse& other); 34 | 35 | Furniture* getFurnitureAtIndex(const int index) const; 36 | }; 37 | 38 | #endif // !FURNITUREHOUSE_H 39 | -------------------------------------------------------------------------------- /practicum/7/Additional-01/Classwork/Task-3/BookStore.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Book.h" 3 | #include "Utils.h" 4 | 5 | class BookStore 6 | { 7 | private: 8 | MyString name; 9 | Book* books; 10 | int booksCount; 11 | public: 12 | BookStore(); 13 | 14 | unsigned sumOfBooksPrice() const; 15 | bool operator<(const BookStore& rhs) const; 16 | void sort(); 17 | ~BookStore(); 18 | }; 19 | 20 | BookStore::BookStore() : name("DefaultName"), books(nullptr), booksCount(0) 21 | { 22 | } 23 | 24 | bool BookStore::operator<(const BookStore &rhs) const 25 | { 26 | return this->sumOfBooksPrice() < rhs.sumOfBooksPrice(); 27 | } 28 | 29 | unsigned int BookStore::sumOfBooksPrice() const 30 | { 31 | unsigned sum = 0; 32 | for (int i = 0; i < booksCount; i++) 33 | { 34 | sum += books[i].getPrice(); 35 | } 36 | return sum; 37 | } 38 | 39 | void BookStore::sort() 40 | { 41 | mergeSort(books,0, booksCount-1); 42 | } 43 | 44 | BookStore::~BookStore() 45 | { 46 | delete[] books; 47 | } 48 | -------------------------------------------------------------------------------- /practicum/3/06, 07 - 08.04.2022/Task 1 & Task 2/DateTime.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class DateTime { 6 | int day; 7 | int month; 8 | int year; 9 | int hour; 10 | int minutes; 11 | 12 | public: 13 | DateTime(); 14 | DateTime(int day, int month, int year, int hour, int minutes); 15 | 16 | int getDay() const; 17 | void setDay(int day); 18 | 19 | int getMonth() const; 20 | void setMonth(int month); 21 | 22 | int getYear() const; 23 | void setYear(int year); 24 | 25 | int getHour() const; 26 | void setHour(int hour); 27 | 28 | int getMinutes() const; 29 | void setMinutes(int minutes); 30 | 31 | void serialize(std::ostream &out) const; 32 | void deserialize(std::istream &in); 33 | 34 | DateTime operator+(const DateTime &o) const; 35 | void operator+=(const DateTime &o); 36 | 37 | friend std::istream &operator>>(std::istream &in, DateTime &d); 38 | friend std::ostream &operator<<(std::ostream &out, const DateTime &d); 39 | }; 40 | -------------------------------------------------------------------------------- /practicum/7/Week-12-Polymorphism/Task-1/Triangle.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Shape.h" 3 | #include 4 | class Triangle: public Shape { 5 | public: 6 | Triangle(double x, double y, const char* color, 7 | double a, double b, double c, 8 | double angle_ab, double angle_bc, double angle_ca) 9 | :Shape(x, y, color), 10 | a(a), b(b), c(c), 11 | angle_ab(angle_ab), angle_bc(angle_bc), angle_ca(angle_ca) 12 | {} 13 | 14 | virtual void print() const override { 15 | std::cout << "Triangle\n"; 16 | Shape::print(); 17 | std::cout << "a: " << a << ", b: " << b << ", c: " << c << "\n"; 18 | std::cout << "angle_ab: " << angle_ab << ", angle_bc: " << angle_bc << ", angle_ca: " << angle_ca << "\n\n"; 19 | } 20 | 21 | virtual double perimeter() const override { 22 | return a + b + c; 23 | } 24 | 25 | virtual double surface() const override { 26 | return 1 / 2 * a * b * sin(angle_ab); 27 | } 28 | 29 | private: 30 | double a; 31 | double b; 32 | double c; 33 | double angle_ab; 34 | double angle_bc; 35 | double angle_ca; 36 | }; -------------------------------------------------------------------------------- /lectures/1/player/hero.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __HERO_HPP 2 | #define __HERO_HPP 3 | #include "player.hpp" 4 | 5 | class Hero : virtual public Player { 6 | unsigned level; 7 | public: 8 | 9 | // конструктор с параметри 10 | Hero(const char* _name = "<анонимен>", 11 | unsigned _score = 0, 12 | unsigned _level = 1); 13 | Hero* clone() const { return new Hero(*this); } 14 | 15 | // селектор 16 | virtual unsigned getLevel() const { return level; } 17 | 18 | // извеждане 19 | void print(std::ostream& os = std::cout) const; 20 | void printDirect(std::ostream& os = std::cout) const; 21 | 22 | static Hero* battle(Hero& hero1, Hero& hero2, unsigned prize = 1); 23 | }; 24 | 25 | 26 | 27 | /* Искаме да реализираме наследник SuperHero на Hero, който: 28 | 29 | - има възможност да активира суперсила 30 | - по подразбиране не е активирана 31 | - като я активира си повишава нивото 32 | - да може да се извежда 33 | - подходящи конструктори, селектори и мутатори 34 | + суперсилата да има име 35 | */ 36 | 37 | #endif -------------------------------------------------------------------------------- /practicum/7/Week-05-Big-four/Theory/Const with classes.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | class Test { 4 | private: 5 | int val; 6 | public: 7 | int getVal() const; 8 | }; 9 | 10 | int Test::getVal() const { 11 | return val; 12 | } 13 | 14 | int main() 15 | { 16 | /* Using const with classes: 17 | * Pass arguments to class member methods as const 18 | * We can also create const objects 19 | * What happens if we call member functions on const objects?? (HINT: ERROR) 20 | * const-correctness 21 | */ 22 | 23 | /* 24 | const Player villain {"Villain", 100, 55}; (villain is a const object so its attributes cannot change) 25 | 26 | void displayPlayerName(const Player& p){ 27 | std::cout << p.getVal() << endl; 28 | } 29 | displayPlayerName(villain); //there will be an error because the compiler is not sure if getVal does not change something ERROR 30 | 31 | 32 | 33 | THE SOLUTION IS: tell the compiler we won't modify the object adding "const" in ending of member functions 34 | std::string getVal() const; 35 | */ 36 | 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /practicum/7/Week-10-Inheritance/Solutions/Task1/Pet.cpp: -------------------------------------------------------------------------------- 1 | #include "Pet.h" 2 | #include 3 | #include 4 | 5 | Pet::Pet():Animal(), owner(nullptr) { 6 | changeOwner("No Owner", 0); 7 | } 8 | 9 | Pet::Pet(const char* name, unsigned age, const char* owner, unsigned phone):Animal(name, age), owner(nullptr) { 10 | changeOwner(owner, phone); 11 | } 12 | 13 | Pet::Pet(const Pet& other):Animal(other), owner(nullptr) { 14 | changeOwner(other.owner, other.phone); 15 | } 16 | 17 | Pet& Pet::operator=(const Pet& other) { 18 | if (this != &other) { 19 | Animal::operator=(other); 20 | changeOwner(other.owner, other.phone); 21 | } 22 | 23 | return *this; 24 | } 25 | Pet::~Pet() { 26 | delete[] owner; 27 | } 28 | 29 | void Pet::print() const { 30 | Animal::print(); 31 | std::cout << owner << ", " << phone << std::endl; 32 | } 33 | void Pet::changeOwner(const char* name, unsigned phone) { 34 | if (owner) 35 | delete[] owner; 36 | 37 | owner = new char[strlen(name) + 1]; 38 | strcpy_s(owner, strlen(name) + 1, name); 39 | 40 | this->phone = phone; 41 | } -------------------------------------------------------------------------------- /lectures/1/player/superhero.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __SUPERHERO_HPP 2 | #define __SUPERHERO_HPP 3 | 4 | #include 5 | #include "hero.hpp" 6 | 7 | class SuperHero : public Hero { 8 | char* power; 9 | bool isActivated; 10 | unsigned levelBoost; 11 | 12 | void setPower(char const* _power); 13 | 14 | public: 15 | SuperHero(char const* _name = "<анонимен>", 16 | unsigned _score = 0, 17 | unsigned _level = 1, 18 | char const* _power = "<мистериозна>", 19 | bool _isActivated = false, 20 | unsigned _levelBoost = 1); 21 | 22 | SuperHero(SuperHero const&); 23 | SuperHero& operator=(SuperHero const&); 24 | ~SuperHero(); 25 | SuperHero* clone() const { return new SuperHero(*this); } 26 | 27 | void activatePower(); 28 | void deactivatePower(); 29 | void print(std::ostream& os = std::cout) const; 30 | unsigned getLevel() const; 31 | 32 | char const* getPower() const { return power; } 33 | bool isUsingPower() const { return isActivated; } 34 | }; 35 | 36 | 37 | #endif -------------------------------------------------------------------------------- /practicum/4/Week11-AbstractClassesAndPolymorphism/lab/solution/Furniture.h: -------------------------------------------------------------------------------- 1 | #ifndef FURNITURE_H 2 | #define FURNITURE_H 3 | 4 | #include 5 | #include 6 | 7 | #include "Utility.h" 8 | 9 | class Furniture { 10 | public: 11 | static int COUNTER; 12 | 13 | public: 14 | void setID(const int newID); 15 | 16 | int getID() const; 17 | 18 | int getQuantity() const; 19 | 20 | void setQuantity(const int quantity); 21 | 22 | double getPrice() const; 23 | 24 | virtual void read(std::istream& in = std::cin); 25 | 26 | virtual const std::string getInfo() const; 27 | 28 | virtual const std::string getStrComparator() const; 29 | 30 | virtual Furniture* clone() = 0; 31 | 32 | protected: 33 | virtual double calculatePrice() const = 0; 34 | 35 | protected: 36 | Furniture(const double height = 0, const double width = 0, const double length = 0, const int quantity = 0); 37 | 38 | protected: 39 | int m_id; 40 | double m_height; 41 | double m_width; 42 | double m_length; 43 | int m_quantity; 44 | double m_price; 45 | }; 46 | 47 | #endif // !FURNITURE_H 48 | -------------------------------------------------------------------------------- /exercises/1/exercises/04-headers-and-testing/vector/int_vector.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class IntVector 6 | { 7 | public: 8 | IntVector() = default; 9 | explicit IntVector(size_t); 10 | IntVector(const IntVector&); // = delete 11 | IntVector& operator=(const IntVector&); 12 | ~IntVector(); 13 | 14 | void print() const; 15 | // method: push_back 16 | // input: 1 integer 17 | // output: void 18 | // add an int to the end of the vector 19 | void push_back(int); 20 | 21 | size_t size() const; 22 | size_t capacity() const; 23 | bool empty() const; 24 | 25 | int * data(); 26 | const int * data() const; 27 | 28 | int& front(); 29 | const int& front() const; 30 | 31 | int& back(); 32 | const int& back() const; 33 | 34 | int& operator[](size_t); 35 | const int& operator[](size_t) const; 36 | 37 | void swap(IntVector&); 38 | private: 39 | int * m_data{nullptr}; 40 | size_t m_size{0}; 41 | size_t m_capacity{0}; 42 | 43 | void expand(size_t); 44 | }; 45 | -------------------------------------------------------------------------------- /exercises/4/week01/week01.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | void solve(int n, int m, int* sol, const int &originalN) { 5 | if ( n == 0 && m == 0 ) { // We have a solution 6 | for (int i = originalN-1; i >= 0; i--) 7 | cout<>n>>m; 38 | int* sol = new (std::nothrow) int[n]; 39 | if (!sol) { // error 40 | return 0; 41 | } 42 | 43 | solve(n, m, sol, n); 44 | delete [] sol; 45 | 46 | return 0; 47 | } 48 | -------------------------------------------------------------------------------- /practicum/4/Week02-MoreStructs/snippets/04-defaultConstructor.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | const std::size_t MAX_NAME_SIZE = 50; 6 | 7 | struct Person 8 | { 9 | char name[MAX_NAME_SIZE]; 10 | int age; 11 | double weight; 12 | 13 | void print() 14 | { 15 | std::cout << "My name is " << this->name << ". I am " << this->age << 16 | " years old and I am " << this->weight << " kg." << std::endl; 17 | } 18 | 19 | Person(const char* name, int age, double weight) 20 | { 21 | strcpy(this->name, name); 22 | this->age = age; 23 | this->weight = weight; 24 | } 25 | 26 | Person() 27 | { 28 | strcpy(this->name, ""); 29 | this->age = 0; 30 | this->weight = 0.0; 31 | } 32 | 33 | // Person() : Person("", 0, 0.0) {} 34 | }; 35 | 36 | int main () 37 | { 38 | Person person("Stefcho", 20, 77.7); 39 | 40 | person.print(); 41 | 42 | Person defaultPerson; 43 | 44 | defaultPerson.print(); 45 | 46 | return 0; 47 | } -------------------------------------------------------------------------------- /exercises/2/week_8_file_read_write+binary/Source.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "ServerFarm.h" 4 | #include "WebServer.h"; 5 | 6 | int main() { 7 | WebServer server; 8 | //server.read(); 9 | //server2.read(); 10 | //server.print(); 11 | //server2.print(); 12 | //std::cout << (server < server2); 13 | //std::cout << (server == server2); 14 | 15 | //std::ofstream out; 16 | //out.open("test.txt"); 17 | //if (out) { 18 | // server.save(out); 19 | //} 20 | //out.close(); 21 | 22 | //std::ifstream in; 23 | //in.open("test.txt"); 24 | //if (in) { 25 | // server.read(in); 26 | //} 27 | //in.close(); 28 | 29 | //server.print(); 30 | ServerFarm farm; 31 | //farm.addServer(server); 32 | //farm.addServer(server); 33 | //farm.addServer(server); 34 | //farm.addServer(server).addServer(server).sort().print(); 35 | //farm.readBin("testBin.dat"); 36 | //farm.print(); 37 | 38 | enum State {NONE = 0, SLEEP = 1, RUNNING = 2}; 39 | 40 | State s; 41 | s = State(3); 42 | 43 | std::cout << s; 44 | 45 | 46 | return 0; 47 | } -------------------------------------------------------------------------------- /practicum/7/Additional-01/Classwork/Task-3/Utils.h: -------------------------------------------------------------------------------- 1 | template 2 | void merge(T* first, int low, int mid, int high){ 3 | int i = low, j = mid + 1, k = low; 4 | T *temp = new T[high + 1]; 5 | while (i <= mid && j <= high) 6 | { 7 | if (first[i] < first[j]) 8 | { 9 | temp[k++] = first[i++]; 10 | } 11 | else 12 | { 13 | temp[k++] = first[j++]; 14 | } 15 | } 16 | 17 | while (i <= mid) 18 | { 19 | temp[k++] = first[i++]; 20 | } 21 | while (j <= high) 22 | { 23 | temp[k++] = first[j++]; 24 | } 25 | 26 | for (int i = low; i <= high; i++) 27 | { 28 | first[i] = temp[i]; 29 | } 30 | delete[] temp; 31 | } 32 | 33 | template 34 | void mergeSort(T* arr, int l, int h){ 35 | int mid; 36 | if (l < h) 37 | { 38 | mid = (l + h) / 2; 39 | mergeSort(arr, l, mid); //разцепваме на все по малки масиви , докато стигнем до 1-елементни масиви, 40 | mergeSort(arr, mid + 1, h); // които са сортирани 41 | merge(arr, l, mid, h); 42 | } 43 | } -------------------------------------------------------------------------------- /practicum/3/14 - 03.06.2022/MeatDish.cpp: -------------------------------------------------------------------------------- 1 | #include "MeatDish.h" 2 | 3 | MeatDish::MeatDish() : Dish(){}; 4 | 5 | MeatDish::MeatDish(const char **ingredients, int time, int numberOfIngredients, Meat meat) 6 | : Dish(ingredients, time, numberOfIngredients) { 7 | this->meat = meat; 8 | }; 9 | 10 | MeatDish::MeatDish(MeatDish const &other) : Dish(other) { 11 | this->meat = other.meat; 12 | }; 13 | 14 | MeatDish MeatDish::operator=(MeatDish const &other) { 15 | if (this != &other) { 16 | 17 | Dish::operator=(other); 18 | this->meat = other.meat; 19 | } 20 | return *this; 21 | }; 22 | 23 | MeatDish::~MeatDish(){}; 24 | 25 | void MeatDish::print() const { 26 | std::cout << "Meat dish with "; 27 | switch (this->meat) { 28 | case Meat::Beef: 29 | std::cout << "beef" << std::endl; 30 | break; 31 | case Meat::Chicken: 32 | std::cout << "chicken" << std::endl; 33 | break; 34 | case Meat::Pork: 35 | std::cout << "pork" << std::endl; 36 | break; 37 | } 38 | Dish::print(); 39 | }; -------------------------------------------------------------------------------- /practicum/4/Week02-MoreStructs/snippets/01-ourFirstMethod.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | const std::size_t MAX_NAME_SIZE = 50; 6 | 7 | struct Person 8 | { 9 | char name[MAX_NAME_SIZE]; 10 | int age; 11 | double weight; 12 | 13 | void print() 14 | { 15 | std::cout << "My name is " << this->name << ". I am " << this->age << 16 | " years old and I am " << this->weight << " kg." << std::endl; 17 | } 18 | }; 19 | 20 | void printPerson(const Person& person) 21 | { 22 | std::cout << "My name is " << person.name << ". I am " << person.age << 23 | " years old and I am " << person.weight << " kg." << std::endl; 24 | } 25 | 26 | void initialize(Person& person, const char* name, int age, double weight) 27 | { 28 | strcpy(person.name, name); 29 | person.age = age; 30 | person.weight = weight; 31 | } 32 | 33 | int main () 34 | { 35 | Person person; 36 | 37 | initialize(person, "Stefcho", 20, 77.7); 38 | 39 | printPerson(person); 40 | person.print(); 41 | 42 | return 0; 43 | } -------------------------------------------------------------------------------- /practicum/4/Week07-Files/snippets/03-commandLineArguments/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(int argc, char** argv) // the 'main' function has arguments, argc - arguments count, argv - the arguments 5 | { 6 | std::cout << "The number of command arguments is: " << argc << std::endl; 7 | for (int i = 0; i < argc; ++i) 8 | { 9 | std::cout << "Argument #" << i+1 << ": " << argv[i] << std::endl; 10 | } 11 | 12 | std::cout << std::endl; 13 | 14 | if (argc == 2) 15 | { 16 | std::ifstream secondArgument(argv[1]); 17 | 18 | if (!secondArgument.is_open()) 19 | { 20 | std::cout << "Problem while opening the file" << std::endl; 21 | return 1; 22 | } 23 | 24 | char tempLine[1000]; 25 | while (!secondArgument.eof()) 26 | { 27 | secondArgument.getline(tempLine, 1000); 28 | std::cout << tempLine << std::endl; 29 | } 30 | } 31 | else 32 | { 33 | std::cout << "Wrong number of arguments" << std::endl; 34 | } 35 | 36 | return 0; 37 | } -------------------------------------------------------------------------------- /practicum/2/01-struct/solutions/problems07-09.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | const int MAX_NAME_LEN = 64; 4 | 5 | struct Student 6 | { 7 | char name[MAX_NAME_LEN]; 8 | unsigned facultyNum; 9 | }; 10 | 11 | 12 | void read(Student& st) 13 | { 14 | std::cin >> st.name >> st.facultyNum; 15 | } 16 | 17 | 18 | void print(const Student& st) 19 | { 20 | std::cout << "Name: " << st.name << ", FN: " << st.facultyNum; 21 | } 22 | 23 | 24 | int main() 25 | { 26 | // const int CONST = 5; // For storing just 5 students 27 | // Student arr[CONST]; 28 | 29 | int numOfStudents; 30 | std::cin >> numOfStudents; 31 | 32 | Student* arr = new (std::nothrow) Student[numOfStudents]; 33 | if (!arr) 34 | { 35 | std::cerr << "Not enough memory!\n"; 36 | return -1; 37 | } 38 | 39 | for (int i = 0; i < numOfStudents; i++) 40 | read(arr[i]); 41 | 42 | std::cout << '\n'; 43 | 44 | for (int i = 0; i < numOfStudents; i++) 45 | { 46 | print(arr[i]); 47 | std::cout << '\n'; 48 | } 49 | 50 | delete[] arr; 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /practicum/7/Additional-01/Classwork/Task-2/TaxiCentral.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "TaxiDriver.h" 3 | #include "Order.h" 4 | class TaxiCentral { 5 | public: 6 | TaxiCentral(const char* name); 7 | TaxiCentral(const TaxiCentral& other); 8 | TaxiCentral& operator=(const TaxiCentral& other); 9 | ~TaxiCentral(); 10 | 11 | void addTaxiDriver(const char* name, size_t salary); 12 | bool makeOrder(const char* sourceAddress, const char*destinationAddress); 13 | bool makeOrder(const char* sourceAddress, const char* destinationAddress, const char* taxiDriverName); 14 | 15 | void cancelOrder(const char* sourceAddress, const char* destinationAddress); 16 | 17 | void printTaxiDrivers() const; 18 | void printOrders() const; 19 | 20 | friend std::ostream& operator<<(std::ostream& out, const TaxiCentral& central); 21 | 22 | private: 23 | void copy(const char* name, TaxiDriver* drivers, Order* orders); 24 | void clear(); 25 | 26 | void dResize(); 27 | void oResize(); 28 | 29 | char* name; 30 | TaxiDriver* drivers; 31 | Order* orders; 32 | 33 | size_t dSize; 34 | size_t oSize; 35 | 36 | size_t dCap; 37 | size_t oCap; 38 | }; --------------------------------------------------------------------------------