├── .gitignore ├── 01.DefiningClasses-Lab ├── 01.BankAccount │ ├── 01.BankAccount.csproj │ ├── BankAccount.cs │ └── Startup.cs ├── 01.DefiningClasses-Lab.sln ├── 02.BankAccountMethods │ ├── 02.BankAccountMethods.csproj │ ├── BankAccount.cs │ └── Startup.cs ├── 03.TestClient │ ├── 03.TestClient.csproj │ ├── BankAccount.cs │ └── Startup.cs └── 04.PersonClass │ ├── 04.PersonClass.csproj │ ├── BankAccount.cs │ ├── Person.cs │ └── Startup.cs ├── 02.DefiningClasses-Exercises ├── 01.DefineClassPerson │ ├── 01.DefineClassPerson.csproj │ ├── Person.cs │ └── Startup.cs ├── 02.CreatingConstructors │ ├── 02.CreatingConstructors.csproj │ ├── Person.cs │ └── Startup.cs ├── 02.DefiningClasses-Exercises.sln ├── 03.OldestFamilyMember │ ├── 03.OldestFamilyMember.csproj │ ├── Family.cs │ ├── Person.cs │ └── Startup.cs ├── 04.OpinionPoll │ ├── 04.OpinionPoll.csproj │ ├── Person.cs │ └── Startup.cs ├── 05.DateModifier │ ├── 05.DateModifier.csproj │ ├── DataModifier.cs │ └── Startup.cs ├── 06.CompanyRoster │ ├── 06.CompanyRoster.csproj │ ├── Employee.cs │ └── Startup.cs ├── 07.SpeedRacing │ ├── 07.SpeedRacing.csproj │ ├── Car.cs │ └── Startup.cs ├── 08.RawData │ ├── 08.RawData.csproj │ ├── Car.cs │ ├── Cargo.cs │ ├── Engine.cs │ ├── Startup.cs │ └── Tire.cs ├── 09.RectangleIntersection │ ├── 09.RectangleIntersection.csproj │ ├── Rectangle.cs │ └── Startup.cs ├── 10.CarSalesman │ ├── 10.CarSalesman.csproj │ ├── Car.cs │ ├── Engine.cs │ └── Startup.cs ├── 11.PokemonTrainer │ ├── 11.PokemonTrainer.csproj │ ├── Pokemon.cs │ ├── Startup.cs │ └── Trainer.cs ├── 12.Google │ ├── 12.Google.csproj │ ├── Car.cs │ ├── Child.cs │ ├── Company.cs │ ├── Parent.cs │ ├── Person.cs │ ├── Pokemon.cs │ └── Startup.cs ├── 13.FamilyTree │ ├── 13.FamilyTree.csproj │ ├── Person.cs │ └── Startup.cs ├── 14.CatLady │ ├── 14.CatLady.csproj │ ├── Cat.cs │ ├── Cymric.cs │ ├── Siamese.cs │ ├── Startup.cs │ └── StreetExtraordinaire.cs └── 15.DrawingTool │ ├── 15.DrawingTool.csproj │ ├── Rectangle.cs │ ├── Shape.cs │ ├── Square.cs │ └── Startup.cs ├── 03.WorkingWithAbstraction-Lab ├── 01.RhombusOfStars │ ├── 01.RhombusOfStars.csproj │ └── Startup.cs ├── 02.PointInRectangle │ ├── 02.PointInRectangle.csproj │ ├── Point.cs │ ├── Rectangle.cs │ └── Startup.cs ├── 03.StudentSystem │ ├── 03.StudentSystem.csproj │ ├── Startup.cs │ ├── Student.cs │ └── StudentSystem.cs ├── 03.WorkingWithAbstraction-Lab.sln └── 04.HotelReservation │ ├── 04.HotelReservation.csproj │ ├── Enums │ ├── DiscountType.cs │ └── Season.cs │ ├── PriceCalculator.cs │ └── Startup.cs ├── 04.WorkingWithAbstraction-Exercises ├── 01.RawData │ ├── 01.RawData.csproj │ ├── Car.cs │ └── Startup.cs ├── 02.CarSalesman │ ├── 02.CarSalesman.csproj │ ├── Car.cs │ ├── Engine.cs │ └── Startup.cs ├── 03.JediGalaxy │ ├── 03.JediGalaxy.csproj │ └── Startup.cs ├── 04.Hospital │ ├── 04.Hospital.csproj │ └── Startup.cs ├── 04.WorkingWithAbstraction-Exercises.sln ├── 05.GreedyTimes │ ├── 05.GreedyTimes.csproj │ └── Startup.cs ├── 06.Sneaking │ ├── 06.Sneaking.csproj │ └── Startup.cs └── 07.FamilyTree │ ├── 07.FamilyTree.csproj │ ├── Person.cs │ └── Startup.cs ├── 05.Encapsulation-Lab ├── 01.SortPersonsByNameAndAge │ ├── 01.SortPersonsByNameAndAge.csproj │ ├── Person.cs │ └── Startup.cs ├── 02.SalaryIncrease │ ├── 02.SalaryIncrease.csproj │ ├── Person.cs │ └── Startup.cs ├── 03.ValidationData │ ├── 03.ValidationData.csproj │ ├── Person.cs │ └── Startup.cs ├── 04.FirstAndReserveTeam │ ├── 04.FirstAndReserveTeam.csproj │ ├── Person.cs │ ├── Startup.cs │ └── Team.cs └── 05.Encapsulation-Lab.sln ├── 06.Encapsulation-Exercises ├── 01.ClassBox │ ├── 01.ClassBox.csproj │ ├── Box.cs │ └── Startup.cs ├── 02.ClassBoxDataValidation │ ├── 02.ClassBoxDataValidation.csproj │ ├── Box.cs │ └── Startup.cs ├── 03.AnimalFarm │ ├── 03.AnimalFarm.csproj │ ├── Chicken.cs │ └── Startup.cs ├── 04.ShoppingSpree │ ├── 04.ShoppingSpree.csproj │ ├── Person.cs │ ├── Product.cs │ └── Startup.cs ├── 05.PizzaCalories │ ├── 05.PizzaCalories.csproj │ ├── Dough.cs │ ├── Pizza.cs │ ├── Startup.cs │ └── Topping.cs ├── 06.Encapsulation-Exercises.sln └── 06.FootballTeamGenerator │ ├── 06.FootballTeamGenerator.csproj │ ├── Player.cs │ ├── Startup.cs │ └── Team.cs ├── 07.Inheritance-Lab ├── 01.SingleInheritance │ ├── 01.SingleInheritance.csproj │ ├── Animal.cs │ ├── Dog.cs │ └── Startup.cs ├── 02.MultiplyInheritance │ ├── 02.MultiplyInheritance.csproj │ ├── Animal.cs │ ├── Dog.cs │ ├── Puppy.cs │ └── Startup.cs ├── 03.HierarchicalInheritance │ ├── 03.HierarchicalInheritance.csproj │ ├── Animal.cs │ ├── Cat.cs │ ├── Dog.cs │ └── Startup.cs ├── 04.RandomList │ ├── 04.RandomList.csproj │ ├── RandomList.cs │ └── Startup.cs ├── 05.StackOfStrings │ ├── 05.StackOfStrings.csproj │ ├── StackOfStrings.cs │ └── Startup.cs └── 07.Inheritance-Lab.sln ├── 08.Inheritance-Exercises ├── 01.Person │ ├── 01.Person.csproj │ ├── Child.cs │ ├── Person.cs │ └── Startup.cs ├── 02.BookShop │ ├── 02.BookShop.csproj │ ├── Book.cs │ ├── GoldenEditionBook.cs │ └── Startup.cs ├── 03.Mankind │ ├── 03.Mankind.csproj │ ├── Human.cs │ ├── Startup.cs │ ├── Student.cs │ └── Worker.cs ├── 04.OnlineRadioDatabase │ ├── 04.OnlineRadioDatabase.csproj │ ├── Exceptions │ │ ├── InvalidArtistNameException.cs │ │ ├── InvalidSongException.cs │ │ ├── InvalidSongLengthException.cs │ │ ├── InvalidSongMinutesException.cs │ │ ├── InvalidSongNameException.cs │ │ └── InvalidSongSecondsException.cs │ ├── Song.cs │ └── Startup.cs ├── 05.MordorsCruelPlan │ ├── 05.MordorsCruelPlan.csproj │ ├── Factories │ │ ├── FoodFactory.cs │ │ └── MoodFactory.cs │ ├── Foods │ │ ├── Apple.cs │ │ ├── Cram.cs │ │ ├── Food.cs │ │ ├── HoneyCake.cs │ │ ├── Lembas.cs │ │ ├── Melon.cs │ │ ├── Mushrooms.cs │ │ └── OtherFood.cs │ ├── Moods │ │ ├── Angry.cs │ │ ├── Happy.cs │ │ ├── JavaScript.cs │ │ ├── Mood.cs │ │ └── Sad.cs │ └── Startup.cs ├── 06.Animals │ ├── 06.Animals.csproj │ ├── Animals │ │ ├── Animal.cs │ │ ├── Cat.cs │ │ ├── Dog.cs │ │ ├── Frog.cs │ │ ├── Kitten.cs │ │ └── Tomcat.cs │ ├── Interfaces │ │ └── IProduceSound.cs │ └── Startup.cs └── 08.Inheritance-Exercises.sln ├── 09.InterfacesAndAbstraction-Lab ├── 01.Shapes │ ├── 01.Shapes.csproj │ ├── Interfaces │ │ └── IDrawable.cs │ ├── Shapes │ │ ├── Circle.cs │ │ └── Rectangle.cs │ └── Startup.cs ├── 02.Cars │ ├── 02.Cars.csproj │ ├── Cars │ │ ├── Seat.cs │ │ └── Tesla.cs │ ├── Interfaces │ │ ├── ICar.cs │ │ └── IElectricCar.cs │ └── Startup.cs └── 09.InterfacesAndAbstraction-Lab.sln ├── 10.InterfacesAndAbstraction-Exercises ├── 01.DefineInterfaceIPerson │ ├── 01.DefineInterfaceIPerson.csproj │ ├── Citizen.cs │ ├── Interfaces │ │ └── IPerson.cs │ └── Startup.cs ├── 02.MultipleImplementation │ ├── 02.MultipleImplementation.csproj │ ├── Citizen.cs │ ├── Interfaces │ │ ├── IBirthable.cs │ │ ├── IIdentifiable.cs │ │ └── IPerson.cs │ └── Startup.cs ├── 03.Ferrari │ ├── 03.Ferrari.csproj │ ├── Ferrari.cs │ ├── Interfaces │ │ └── ICar.cs │ └── Startup.cs ├── 04.Telephony │ ├── 04.Telephony.csproj │ ├── Interfaces │ │ ├── IBrowsable.cs │ │ └── IPhone.cs │ ├── Smartphone.cs │ └── Startup.cs ├── 05.BorderControl │ ├── 05.BorderControl.csproj │ ├── Interfaces │ │ ├── ICitizen.cs │ │ ├── IId.cs │ │ └── IRobot.cs │ ├── Models │ │ ├── Citizen.cs │ │ └── Robot.cs │ └── Startup.cs ├── 06.BirthdayCelebrations │ ├── 06.BirthdayCelebrations.csproj │ ├── Interfaces │ │ ├── IBirthdate.cs │ │ ├── ICitizen.cs │ │ ├── IId.cs │ │ ├── IPet.cs │ │ └── IRobot.cs │ ├── Models │ │ ├── Citizen.cs │ │ ├── Pet.cs │ │ └── Robot.cs │ └── Startup.cs ├── 07.FoodShortage │ ├── 07.FoodShortage.csproj │ ├── Interfaces │ │ ├── IBirthdate.cs │ │ ├── IBuyer.cs │ │ ├── ICitizen.cs │ │ ├── IId.cs │ │ └── IRebel.cs │ ├── Models │ │ ├── Citizen.cs │ │ └── Rebel.cs │ └── Startup.cs ├── 08.MilitaryElite │ ├── 08.MilitaryElite.csproj │ ├── Interfaces │ │ ├── ICommando.cs │ │ ├── IEngineer.cs │ │ ├── ILeutenantGeneral.cs │ │ ├── IMission.cs │ │ ├── IPrivate.cs │ │ ├── IRepair.cs │ │ ├── ISoldier.cs │ │ ├── ISpecialisedSoldier.cs │ │ └── ISpy.cs │ ├── Models │ │ ├── Commando.cs │ │ ├── Engineer.cs │ │ ├── LeutenantGeneral.cs │ │ ├── Mission.cs │ │ ├── Private.cs │ │ ├── Repair.cs │ │ ├── Soldier.cs │ │ ├── SpecialisedSoldier.cs │ │ └── Spy.cs │ └── Startup.cs ├── 09.CollectionHierarchy │ ├── 09.CollectionHierarchy.csproj │ ├── Interfaces │ │ ├── IAddable.cs │ │ ├── IMyList.cs │ │ └── IRemovable.cs │ ├── Models │ │ ├── AddCollection.cs │ │ ├── AddRemoveCollection.cs │ │ └── MyList.cs │ └── Startup.cs ├── 10.ExplicitInterfaces │ ├── 10.ExplicitInterfaces.csproj │ ├── Citizen.cs │ ├── Interfaces │ │ ├── IPerson.cs │ │ └── IResident.cs │ └── Startup.cs └── 10.InterfacesAndAbstraction-Exercises.sln ├── 11.Polymorphism-Lab ├── 01.MathOperation │ ├── 01.MathOperation.csproj │ ├── MathOperations.cs │ └── Startup.cs ├── 02.Animals │ ├── 02.Animals.csproj │ ├── Models │ │ ├── Animal.cs │ │ ├── Cat.cs │ │ └── Dog.cs │ └── Startup.cs ├── 03.Shapes │ ├── 03.Shapes.csproj │ ├── Models │ │ ├── Circle.cs │ │ ├── Rectangle.cs │ │ └── Shape.cs │ ├── Startup.cs │ └── Validators │ │ └── Validator.cs └── 11.Polymorphism-Lab.sln ├── 12.Polymorphism-Exercises ├── 01.Vehicles │ ├── 01.Vehicles.csproj │ ├── Models │ │ ├── Car.cs │ │ ├── Truck.cs │ │ └── Vehicle.cs │ └── Startup.cs ├── 02.VehiclesExtension │ ├── 02.VehiclesExtension.csproj │ ├── Models │ │ ├── Bus.cs │ │ ├── Car.cs │ │ ├── Truck.cs │ │ └── Vehicle.cs │ ├── Startup.cs │ └── Validations │ │ └── Validator.cs ├── 03.WildFarm │ ├── 03.WildFarm.csproj │ ├── Animals │ │ ├── Animal.cs │ │ ├── Birds │ │ │ ├── Bird.cs │ │ │ ├── Hen.cs │ │ │ └── Owl.cs │ │ └── Mammals │ │ │ ├── Dog.cs │ │ │ ├── Felines │ │ │ ├── Cat.cs │ │ │ ├── Feline.cs │ │ │ └── Tiger.cs │ │ │ ├── Mammal.cs │ │ │ └── Mouse.cs │ ├── Factories │ │ ├── AnimalFactory.cs │ │ └── FoodFactory.cs │ ├── Food │ │ ├── Food.cs │ │ ├── Fruit.cs │ │ ├── Meat.cs │ │ ├── Seeds.cs │ │ └── Vegetable.cs │ ├── Startup.cs │ └── Validations │ │ └── Validator.cs └── 12.Polymorphism-Exercises.sln ├── Exam-07.09.2017-GrandPrix ├── Exam-07.09.2017-GrandPrix.sln └── GrandPrix │ ├── Controller │ ├── Engine.cs │ └── RaceTower.cs │ ├── Exceptions │ └── ErrorMessage.cs │ ├── Factories │ ├── CarFactory.cs │ ├── DriverFactory.cs │ └── TyreFactory.cs │ ├── GrandPrix.csproj │ ├── Models │ ├── Cars │ │ └── Car.cs │ ├── Drivers │ │ ├── AggressiveDriver.cs │ │ ├── Driver.cs │ │ └── EnduranceDriver.cs │ ├── Track.cs │ └── Tyres │ │ ├── HardTyre.cs │ │ ├── Tyre.cs │ │ └── UltrasoftTyre.cs │ └── Startup.cs ├── Exam-11.07.2017-NeedForSpeed ├── Exam-11.07.2017-NeedForSpeed.sln └── NeedForSpeed │ ├── Controller │ ├── CarManager.cs │ └── Engine.cs │ ├── Models │ ├── Cars │ │ ├── Car.cs │ │ ├── PerformanceCar.cs │ │ └── ShowCar.cs │ ├── Garage │ │ └── Garage.cs │ └── Races │ │ ├── CasualRace.cs │ │ ├── CircuitRace.cs │ │ ├── DragRace.cs │ │ ├── DriftRace.cs │ │ ├── Race.cs │ │ └── TimeLimitRace.cs │ ├── NeedForSpeed.csproj │ └── Startup.cs ├── Exam-12.07.2017-Avatar ├── Avatar │ ├── Avatar.csproj │ ├── Controller │ │ ├── Engine.cs │ │ └── NationsBuilder.cs │ ├── Models │ │ ├── Benders │ │ │ ├── AirBender.cs │ │ │ ├── Bender.cs │ │ │ ├── EarthBender.cs │ │ │ ├── FireBender.cs │ │ │ └── WaterBender.cs │ │ ├── Monuments │ │ │ ├── AirMonument.cs │ │ │ ├── EarthMonument.cs │ │ │ ├── FireMonument.cs │ │ │ ├── Monument.cs │ │ │ └── WaterMonument.cs │ │ └── Nation.cs │ └── Startup.cs └── Exam-12.07.2017-Avatar.sln ├── Exam-16.07.2017-Minedraft ├── Exam-16.07.2017-Minedraft.sln ├── Minedraft-Framework │ ├── App.config │ ├── Controller │ │ ├── DraftManager.cs │ │ └── Engine.cs │ ├── Factories │ │ ├── HarvesterFactory.cs │ │ └── ProviderFactory.cs │ ├── Minedraft-Framework.csproj │ ├── Models │ │ ├── Harvesters │ │ │ ├── HammerHarvester.cs │ │ │ ├── Harvester.cs │ │ │ └── SonicHarvester.cs │ │ ├── Machine.cs │ │ └── Providers │ │ │ ├── PressureProvider.cs │ │ │ ├── Provider.cs │ │ │ └── SolarProvider.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ └── Startup.cs └── Minedraft │ ├── Controller │ ├── DraftManager.cs │ └── Engine.cs │ ├── Factories │ ├── HarvesterFactory.cs │ └── ProviderFactory.cs │ ├── Minedraft.csproj │ ├── Models │ ├── Harvesters │ │ ├── HammerHarvester.cs │ │ ├── Harvester.cs │ │ └── SonicHarvester.cs │ ├── Machine.cs │ └── Providers │ │ ├── PressureProvider.cs │ │ ├── Provider.cs │ │ └── SolarProvider.cs │ ├── Startup.cs │ └── Validations │ └── Validator.cs ├── Exam-18.03.2018-DungeonsAndCodeWizards ├── DungeonsAndCodeWizards │ ├── Controllers │ │ ├── DungeonMaster.cs │ │ └── Engine.cs │ ├── DungeonsAndCodeWizards.csproj │ ├── Factories │ │ ├── CharacterFactory.cs │ │ └── ItemFactory.cs │ ├── Models │ │ ├── Bags │ │ │ ├── Backpack.cs │ │ │ ├── Bag.cs │ │ │ └── Satchel.cs │ │ ├── Characters │ │ │ ├── Character.cs │ │ │ ├── Cleric.cs │ │ │ └── Warrior.cs │ │ ├── Enums │ │ │ └── Faction.cs │ │ ├── Interfaces │ │ │ ├── IAttackable.cs │ │ │ └── IHealable.cs │ │ └── Items │ │ │ ├── ArmorRepairKit.cs │ │ │ ├── HealthPotion.cs │ │ │ ├── Item.cs │ │ │ └── PoisonPotion.cs │ └── StartUp.cs └── Exam-18.03.2018-DungeonsAndCodeWizards.sln ├── Exam-26.04.2018-StorageMaster ├── Exam-26.04.2018-StorageMaster.sln └── StorageMaster │ ├── Core │ ├── Engine.cs │ └── StorageMaster.cs │ ├── Factories │ ├── ProductFactory.cs │ ├── StorageFactory.cs │ └── VehicleFactory.cs │ ├── Models │ ├── Products │ │ ├── Gpu.cs │ │ ├── HardDrive.cs │ │ ├── Product.cs │ │ ├── Ram.cs │ │ └── SolidStateDrive.cs │ ├── Storages │ │ ├── AutomatedWarehouse.cs │ │ ├── DistributionCenter.cs │ │ ├── Storage.cs │ │ └── Warehouse.cs │ └── Vehicles │ │ ├── Semi.cs │ │ ├── Truck.cs │ │ ├── Van.cs │ │ └── Vehicle.cs │ ├── OutputMessages │ └── OutputMessage.cs │ ├── StartUp.cs │ └── StorageMaster.csproj ├── README.md ├── Resources ├── 01. Defining-Classes-Lab.docx ├── 02. Defining-Classes-Exercises.docx ├── 03. Working-with-Abstraction-Lab.docx ├── 04. Working-with-Abstraction-Exercises.docx ├── 05. Encapsulation-Lab.docx ├── 06. Encapsulation-Exercises.docx ├── 07. Inheritance-Lab.docx ├── 08. Inheritance-Exercises.docx ├── 09. Interfaces-and-Abstraction-Lab.docx ├── 10. Interfaces-and-Abstraction-Exercises.docx ├── 11. Polymorphism-Lab.docx ├── 12. Polymorphism-Exercises.docx ├── Exam-05.09.2017-Grand-Prix │ └── Grand-Prix.docx ├── Exam-11.07.2017-Need-For-Speed │ └── Need-For-Speed.docx ├── Exam-12.07.2017-Avatar │ └── Avatar.docx ├── Exam-16.07.2017-Minedraft │ └── Minedraft.docx ├── Exam-18.03.2018-Dungeons-and-Code-Wizards │ └── DungeonsAndCodeWizards.docx ├── Exam-26.04.2018-Storage-Master │ └── Storage-Master.docx └── Workshop │ ├── Workshop-Forum-Part-1.docx │ ├── Workshop-Forum-Part-2.docx │ └── Workshop-Forum-Part-3.docx └── Workshop-Forum ├── Forum.App ├── Controllers │ ├── AddPostController.cs │ ├── AddReplyController.cs │ ├── CategoriesController.cs │ ├── CategoryController.cs │ ├── Contracts │ │ ├── IController.cs │ │ ├── IPaginationController.cs │ │ ├── IReadUserInfoController.cs │ │ └── IUserRestrictedController.cs │ ├── LoginController.cs │ ├── MainController.cs │ ├── PostDetailsController.cs │ └── SignUpController.cs ├── Core │ ├── Engine.cs │ └── MenuController.cs ├── Enums │ ├── MenuState.cs │ └── SignUpStatus.cs ├── Exceptions │ └── InvalidCommandException.cs ├── Forum.App.csproj ├── Services │ ├── PostService.cs │ └── UserService.cs ├── StartUp.cs └── UserInterface │ ├── Contracts │ ├── IInput.cs │ ├── ILabel.cs │ ├── IPositionable.cs │ └── IView.cs │ ├── ForumViewEngine.cs │ ├── Input │ ├── StringProcessor.cs │ └── TextArea.cs │ ├── Label.cs │ ├── Position.cs │ ├── ViewModels │ ├── PostViewModel.cs │ └── ReplyViewModel.cs │ └── Views │ ├── AddPostView.cs │ ├── AddReplyView.cs │ ├── CategoriesView.cs │ ├── CategoryView.cs │ ├── LogInView.cs │ ├── MainView.cs │ ├── PostDetailsView.cs │ └── SignUpView.cs ├── Forum.Data ├── DataMapper.cs ├── Forum.Data.csproj └── ForumData.cs ├── Forum.Models ├── Category.cs ├── Forum.Models.csproj ├── Post.cs ├── Reply.cs └── User.cs └── Workshop-Forum.sln /01.DefiningClasses-Lab/01.BankAccount/01.BankAccount.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /01.DefiningClasses-Lab/01.BankAccount/BankAccount.cs: -------------------------------------------------------------------------------- 1 | public class BankAccount 2 | { 3 | private int id; 4 | private double balance; 5 | 6 | public double Balance 7 | { 8 | get { return this.balance; } 9 | set { this.balance = value; } 10 | } 11 | 12 | public int Id 13 | { 14 | get { return this.id; } 15 | set { this.id = value; } 16 | } 17 | } -------------------------------------------------------------------------------- /01.DefiningClasses-Lab/01.BankAccount/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public class Startup 4 | { 5 | public static void Main() 6 | { 7 | BankAccount account = new BankAccount(); 8 | account.Id = 1; 9 | account.Balance = 100; 10 | 11 | Console.WriteLine($"Account {account.Id}, balance {account.Balance}"); 12 | } 13 | } -------------------------------------------------------------------------------- /01.DefiningClasses-Lab/02.BankAccountMethods/02.BankAccountMethods.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /01.DefiningClasses-Lab/02.BankAccountMethods/BankAccount.cs: -------------------------------------------------------------------------------- 1 | public class BankAccount 2 | { 3 | private int id; 4 | private decimal balance; 5 | 6 | public decimal Balance 7 | { 8 | get { return this.balance; } 9 | set { this.balance = value; } 10 | } 11 | 12 | public int Id 13 | { 14 | get { return this.id; } 15 | set { this.id = value; } 16 | } 17 | 18 | public void Deposit(decimal amount) 19 | { 20 | this.Balance += amount; 21 | } 22 | 23 | public void Withdraw(decimal amount) 24 | { 25 | this.Balance -= amount; 26 | } 27 | 28 | public override string ToString() 29 | { 30 | return $"Account {this.Id}, balance {this.Balance}"; 31 | } 32 | } -------------------------------------------------------------------------------- /01.DefiningClasses-Lab/02.BankAccountMethods/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public class Startup 4 | { 5 | public static void Main() 6 | { 7 | BankAccount account = new BankAccount(); 8 | account.Id = 1; 9 | account.Deposit(100); 10 | account.Withdraw(25); 11 | 12 | Console.WriteLine(account.ToString()); 13 | } 14 | } -------------------------------------------------------------------------------- /01.DefiningClasses-Lab/03.TestClient/03.TestClient.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /01.DefiningClasses-Lab/03.TestClient/BankAccount.cs: -------------------------------------------------------------------------------- 1 | public class BankAccount 2 | { 3 | private int id; 4 | private decimal balance; 5 | 6 | public decimal Balance 7 | { 8 | get { return this.balance; } 9 | set { this.balance = value; } 10 | } 11 | 12 | public int Id 13 | { 14 | get { return this.id; } 15 | set { this.id = value; } 16 | } 17 | 18 | public void Deposit(decimal amount) 19 | { 20 | this.Balance += amount; 21 | } 22 | 23 | public void Withdraw(decimal amount) 24 | { 25 | this.Balance -= amount; 26 | } 27 | 28 | public override string ToString() 29 | { 30 | return $"Account {this.Id}, balance {this.Balance}"; 31 | } 32 | } -------------------------------------------------------------------------------- /01.DefiningClasses-Lab/04.PersonClass/04.PersonClass.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /01.DefiningClasses-Lab/04.PersonClass/BankAccount.cs: -------------------------------------------------------------------------------- 1 | public class BankAccount 2 | { 3 | private int id; 4 | private decimal balance; 5 | 6 | public decimal Balance 7 | { 8 | get { return this.balance; } 9 | set { this.balance = value; } 10 | } 11 | 12 | public int Id 13 | { 14 | get { return this.id; } 15 | set { this.id = value; } 16 | } 17 | 18 | public void Deposit(decimal amount) 19 | { 20 | this.Balance += amount; 21 | } 22 | 23 | public void Withdraw(decimal amount) 24 | { 25 | this.Balance -= amount; 26 | } 27 | 28 | public override string ToString() 29 | { 30 | return $"Account {this.Id}, balance {this.Balance}"; 31 | } 32 | } -------------------------------------------------------------------------------- /01.DefiningClasses-Lab/04.PersonClass/Person.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | 4 | public class Person 5 | { 6 | private string name; 7 | private int age; 8 | private List accounts; 9 | 10 | public Person(string name, int age) 11 | : this(name, age, new List()) 12 | { 13 | } 14 | 15 | public Person(string name, int age, List accounts) 16 | { 17 | this.name = name; 18 | this.age = age; 19 | this.accounts = accounts; 20 | } 21 | 22 | public List Accounts 23 | { 24 | get { return this.accounts; } 25 | set { this.accounts = value; } 26 | } 27 | 28 | public int Age 29 | { 30 | get { return this.age; } 31 | set { this.age = value; } 32 | } 33 | 34 | public string Name 35 | { 36 | get { return this.name; } 37 | set { this.name = value; } 38 | } 39 | 40 | public decimal GetBalance() 41 | { 42 | decimal balance = this.accounts.Sum(a => a.Balance); 43 | return balance; 44 | } 45 | } -------------------------------------------------------------------------------- /01.DefiningClasses-Lab/04.PersonClass/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | public class Startup 5 | { 6 | public static void Main() 7 | { 8 | BankAccount firstAccount = new BankAccount(); 9 | firstAccount.Id = 1; 10 | firstAccount.Balance = 100; 11 | 12 | BankAccount secondAccount = new BankAccount(); 13 | secondAccount.Id = 1; 14 | secondAccount.Balance = 200; 15 | 16 | List accounts = new List { firstAccount, secondAccount }; 17 | Person person = new Person("Ivan", 20, accounts); 18 | 19 | Console.WriteLine($"Name: {person.Name}, age: {person.Age}, total balance: {person.GetBalance():F2}"); 20 | } 21 | } -------------------------------------------------------------------------------- /02.DefiningClasses-Exercises/01.DefineClassPerson/01.DefineClassPerson.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /02.DefiningClasses-Exercises/01.DefineClassPerson/Person.cs: -------------------------------------------------------------------------------- 1 | public class Person 2 | { 3 | private string name; 4 | private int age; 5 | 6 | public int Age 7 | { 8 | get { return this.age; } 9 | set { this.age = value; } 10 | } 11 | 12 | public string Name 13 | { 14 | get { return this.name; } 15 | set { this.name = value; } 16 | } 17 | } -------------------------------------------------------------------------------- /02.DefiningClasses-Exercises/01.DefineClassPerson/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public class Startup 4 | { 5 | public static void Main() 6 | { 7 | Person person = new Person(); 8 | person.Name = "Ivan"; 9 | person.Age = 20; 10 | 11 | Console.WriteLine($"{person.Name} {person.Age}"); 12 | } 13 | } -------------------------------------------------------------------------------- /02.DefiningClasses-Exercises/02.CreatingConstructors/02.CreatingConstructors.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /02.DefiningClasses-Exercises/02.CreatingConstructors/Person.cs: -------------------------------------------------------------------------------- 1 | public class Person 2 | { 3 | private string name; 4 | private int age; 5 | 6 | public Person() 7 | : this("No name", 1) 8 | { 9 | } 10 | 11 | public Person(int age) 12 | : this("No name", age) 13 | { 14 | } 15 | 16 | public Person(string name, int age) 17 | { 18 | this.Name = name; 19 | this.Age = age; 20 | } 21 | 22 | public int Age 23 | { 24 | get { return this.age; } 25 | set { this.age = value; } 26 | } 27 | 28 | public string Name 29 | { 30 | get { return this.name; } 31 | set { this.name = value; } 32 | } 33 | } -------------------------------------------------------------------------------- /02.DefiningClasses-Exercises/02.CreatingConstructors/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public class Startup 4 | { 5 | public static void Main() 6 | { 7 | Person person = new Person("Ivan", 20); 8 | Console.WriteLine($"{person.Name} {person.Age}"); 9 | } 10 | } -------------------------------------------------------------------------------- /02.DefiningClasses-Exercises/03.OldestFamilyMember/03.OldestFamilyMember.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /02.DefiningClasses-Exercises/03.OldestFamilyMember/Family.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | 4 | public class Family 5 | { 6 | public List people = new List(); 7 | 8 | public void AddMember(Person person) 9 | { 10 | this.people.Add(person); 11 | } 12 | 13 | public Person GetOldestMember() 14 | { 15 | Person person = this.people.OrderByDescending(p => p.Age).FirstOrDefault(); 16 | return person; 17 | } 18 | } -------------------------------------------------------------------------------- /02.DefiningClasses-Exercises/03.OldestFamilyMember/Person.cs: -------------------------------------------------------------------------------- 1 | public class Person 2 | { 3 | private string name; 4 | private int age; 5 | 6 | public Person(string name, int age) 7 | { 8 | this.Name = name; 9 | this.Age = age; 10 | } 11 | 12 | public int Age 13 | { 14 | get { return this.age; } 15 | set { this.age = value; } 16 | } 17 | 18 | public string Name 19 | { 20 | get { return this.name; } 21 | set { this.name = value; } 22 | } 23 | } -------------------------------------------------------------------------------- /02.DefiningClasses-Exercises/03.OldestFamilyMember/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public class Startup 4 | { 5 | public static void Main() 6 | { 7 | int number = int.Parse(Console.ReadLine()); 8 | Family family = new Family(); 9 | for (int i = 0; i < number; i++) 10 | { 11 | string[] inputParts = Console.ReadLine().Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries); 12 | string name = inputParts[0]; 13 | int age = int.Parse(inputParts[1]); 14 | Person person = new Person(name, age); 15 | family.AddMember(person); 16 | } 17 | 18 | Person oldestPerson = family.GetOldestMember(); 19 | Console.WriteLine($"{oldestPerson.Name} {oldestPerson.Age}"); 20 | } 21 | } -------------------------------------------------------------------------------- /02.DefiningClasses-Exercises/04.OpinionPoll/04.OpinionPoll.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /02.DefiningClasses-Exercises/04.OpinionPoll/Person.cs: -------------------------------------------------------------------------------- 1 | namespace OpinionPoll 2 | { 3 | public class Person 4 | { 5 | private string name; 6 | private int age; 7 | 8 | public Person(string name, int age) 9 | { 10 | this.Name = name; 11 | this.Age = age; 12 | } 13 | 14 | public int Age 15 | { 16 | get { return this.age; } 17 | set { this.age = value; } 18 | } 19 | 20 | public string Name 21 | { 22 | get { return this.name; } 23 | set { this.name = value; } 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /02.DefiningClasses-Exercises/04.OpinionPoll/Startup.cs: -------------------------------------------------------------------------------- 1 | namespace OpinionPoll 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | 7 | public class Startup 8 | { 9 | public static void Main() 10 | { 11 | int number = int.Parse(Console.ReadLine()); 12 | List people = new List(); 13 | 14 | for (int i = 0; i < number; i++) 15 | { 16 | string[] inputParts = Console.ReadLine().Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries); 17 | string name = inputParts[0]; 18 | int age = int.Parse(inputParts[1]); 19 | Person person = new Person(name, age); 20 | people.Add(person); 21 | } 22 | 23 | people.Where(p => p.Age > 30) 24 | .OrderBy(p => p.Name) 25 | .ToList() 26 | .ForEach(p => Console.WriteLine($"{p.Name} - {p.Age}")); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /02.DefiningClasses-Exercises/05.DateModifier/05.DateModifier.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /02.DefiningClasses-Exercises/05.DateModifier/DataModifier.cs: -------------------------------------------------------------------------------- 1 | namespace DateModifier 2 | { 3 | using System; 4 | 5 | public class DataModifier 6 | { 7 | public double CalculateDays(DateTime firstDate, DateTime secondDate) 8 | { 9 | return Math.Abs((firstDate - secondDate).TotalDays); 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /02.DefiningClasses-Exercises/05.DateModifier/Startup.cs: -------------------------------------------------------------------------------- 1 | namespace DateModifier 2 | { 3 | using System; 4 | 5 | public class Startup 6 | { 7 | public static void Main() 8 | { 9 | string firstInput = Console.ReadLine(); 10 | string secondInput = Console.ReadLine(); 11 | 12 | DateTime firstDate = DateTime.ParseExact(firstInput, "yyyy MM dd", null); 13 | DateTime secondDate = DateTime.ParseExact(secondInput, "yyyy MM dd", null); 14 | 15 | DataModifier dateModifier = new DataModifier(); 16 | Console.WriteLine(dateModifier.CalculateDays(firstDate, secondDate)); 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /02.DefiningClasses-Exercises/06.CompanyRoster/06.CompanyRoster.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /02.DefiningClasses-Exercises/07.SpeedRacing/07.SpeedRacing.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /02.DefiningClasses-Exercises/08.RawData/08.RawData.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /02.DefiningClasses-Exercises/08.RawData/Cargo.cs: -------------------------------------------------------------------------------- 1 | namespace RawData 2 | { 3 | public class Cargo 4 | { 5 | private int weight; 6 | private string type; 7 | 8 | public Cargo(int weight, string type) 9 | { 10 | this.Weight = weight; 11 | this.Type = type; 12 | } 13 | 14 | public string Type 15 | { 16 | get { return this.type; } 17 | set { this.type = value; } 18 | } 19 | 20 | public int Weight 21 | { 22 | get { return this.weight; } 23 | set { this.weight = value; } 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /02.DefiningClasses-Exercises/08.RawData/Engine.cs: -------------------------------------------------------------------------------- 1 | namespace RawData 2 | { 3 | public class Engine 4 | { 5 | private int speed; 6 | private int power; 7 | 8 | public Engine(int speed, int power) 9 | { 10 | this.Speed = speed; 11 | this.Power = power; 12 | } 13 | 14 | public int Power 15 | { 16 | get { return this.power; } 17 | set { this.power = value; } 18 | } 19 | 20 | public int Speed 21 | { 22 | get { return this.speed; } 23 | set { this.speed = value; } 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /02.DefiningClasses-Exercises/08.RawData/Tire.cs: -------------------------------------------------------------------------------- 1 | namespace RawData 2 | { 3 | public class Tire 4 | { 5 | private double pressure; 6 | private double age; 7 | 8 | public Tire(double pressure, double age) 9 | { 10 | this.Pressure = pressure; 11 | this.Age = age; 12 | } 13 | 14 | public double Age 15 | { 16 | get { return this.age; } 17 | set { this.age = value; } 18 | } 19 | 20 | public double Pressure 21 | { 22 | get { return this.pressure; } 23 | set { this.pressure = value; } 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /02.DefiningClasses-Exercises/09.RectangleIntersection/09.RectangleIntersection.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /02.DefiningClasses-Exercises/10.CarSalesman/10.CarSalesman.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /02.DefiningClasses-Exercises/11.PokemonTrainer/11.PokemonTrainer.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /02.DefiningClasses-Exercises/11.PokemonTrainer/Pokemon.cs: -------------------------------------------------------------------------------- 1 | namespace PokemonTrainer 2 | { 3 | public class Pokemon 4 | { 5 | private string name; 6 | private string element; 7 | private int health; 8 | 9 | public Pokemon(string name, string element, int health) 10 | { 11 | this.Name = name; 12 | this.Element = element; 13 | this.Health = health; 14 | } 15 | 16 | public int Health 17 | { 18 | get { return this.health; } 19 | set { this.health = value; } 20 | } 21 | 22 | public string Element 23 | { 24 | get { return this.element; } 25 | set { this.element = value; } 26 | } 27 | 28 | public string Name 29 | { 30 | get { return this.name; } 31 | set { this.name = value; } 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /02.DefiningClasses-Exercises/11.PokemonTrainer/Trainer.cs: -------------------------------------------------------------------------------- 1 | namespace PokemonTrainer 2 | { 3 | using System.Collections.Generic; 4 | 5 | public class Trainer 6 | { 7 | private string name; 8 | private int badges; 9 | private List pokemons; 10 | 11 | public Trainer(string name) 12 | { 13 | this.Name = name; 14 | this.Badges = 0; 15 | this.Pokemons = new List(); 16 | } 17 | 18 | public List Pokemons 19 | { 20 | get { return this.pokemons; } 21 | set { this.pokemons = value; } 22 | } 23 | 24 | public int Badges 25 | { 26 | get { return this.badges; } 27 | set { this.badges = value; } 28 | } 29 | 30 | public string Name 31 | { 32 | get { return this.name; } 33 | set { this.name = value; } 34 | } 35 | 36 | public override string ToString() 37 | { 38 | return $"{this.Name} {this.Badges} {this.Pokemons.Count}"; 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /02.DefiningClasses-Exercises/12.Google/12.Google.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /02.DefiningClasses-Exercises/12.Google/Car.cs: -------------------------------------------------------------------------------- 1 | namespace Google 2 | { 3 | public class Car 4 | { 5 | private string model; 6 | private int speed; 7 | 8 | public Car(string model, int speed) 9 | { 10 | this.Model = model; 11 | this.Speed = speed; 12 | } 13 | 14 | public int Speed 15 | { 16 | get { return this.speed; } 17 | set { this.speed = value; } 18 | } 19 | 20 | public string Model 21 | { 22 | get { return this.model; } 23 | set { this.model = value; } 24 | } 25 | 26 | public override string ToString() 27 | { 28 | return $"{this.Model} {this.Speed}"; 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /02.DefiningClasses-Exercises/12.Google/Child.cs: -------------------------------------------------------------------------------- 1 | namespace Google 2 | { 3 | public class Child 4 | { 5 | private string name; 6 | private string birthday; 7 | 8 | public Child(string name, string birthday) 9 | { 10 | this.Name = name; 11 | this.Birthday = birthday; 12 | } 13 | 14 | public string Birthday 15 | { 16 | get { return this.birthday; } 17 | set { this.birthday = value; } 18 | } 19 | 20 | public string Name 21 | { 22 | get { return this.name; } 23 | set { this.name = value; } 24 | } 25 | 26 | public override string ToString() 27 | { 28 | return $"{this.Name} {this.Birthday}"; 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /02.DefiningClasses-Exercises/12.Google/Company.cs: -------------------------------------------------------------------------------- 1 | namespace Google 2 | { 3 | public class Company 4 | { 5 | private string name; 6 | private string department; 7 | private decimal salary; 8 | 9 | public Company(string name, string department, decimal salary) 10 | { 11 | this.Name = name; 12 | this.Department = department; 13 | this.Salary = salary; 14 | } 15 | 16 | public decimal Salary 17 | { 18 | get { return this.salary; } 19 | set { this.salary = value; } 20 | } 21 | 22 | public string Department 23 | { 24 | get { return this.department; } 25 | set { this.department = value; } 26 | } 27 | 28 | public string Name 29 | { 30 | get { return this.name; } 31 | set { this.name = value; } 32 | } 33 | 34 | public override string ToString() 35 | { 36 | return $"{this.Name} {this.Department} {this.Salary:F2}"; 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /02.DefiningClasses-Exercises/12.Google/Parent.cs: -------------------------------------------------------------------------------- 1 | namespace Google 2 | { 3 | public class Parent 4 | { 5 | private string name; 6 | private string birthday; 7 | 8 | public Parent(string name, string birthday) 9 | { 10 | this.Name = name; 11 | this.Birthday = birthday; 12 | } 13 | 14 | public string Birthday 15 | { 16 | get { return this.birthday; } 17 | set { this.birthday = value; } 18 | } 19 | 20 | public string Name 21 | { 22 | get { return this.name; } 23 | set { this.name = value; } 24 | } 25 | 26 | public override string ToString() 27 | { 28 | return $"{this.Name} {this.Birthday}"; 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /02.DefiningClasses-Exercises/12.Google/Pokemon.cs: -------------------------------------------------------------------------------- 1 | namespace Google 2 | { 3 | public class Pokemon 4 | { 5 | private string name; 6 | private string type; 7 | 8 | public Pokemon(string name, string type) 9 | { 10 | this.Name = name; 11 | this.Type = type; 12 | } 13 | 14 | public string Type 15 | { 16 | get { return this.type; } 17 | set { this.type = value; } 18 | } 19 | 20 | public string Name 21 | { 22 | get { return this.name; } 23 | set { this.name = value; } 24 | } 25 | 26 | public override string ToString() 27 | { 28 | return $"{this.Name} {this.Type}"; 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /02.DefiningClasses-Exercises/13.FamilyTree/13.FamilyTree.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /02.DefiningClasses-Exercises/14.CatLady/14.CatLady.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /02.DefiningClasses-Exercises/14.CatLady/Cat.cs: -------------------------------------------------------------------------------- 1 | namespace CatLady 2 | { 3 | public abstract class Cat 4 | { 5 | private string name; 6 | 7 | protected Cat(string name) 8 | { 9 | this.Name = name; 10 | } 11 | 12 | public string Name 13 | { 14 | get { return this.name; } 15 | set { this.name = value; } 16 | } 17 | 18 | public override string ToString() 19 | { 20 | return $"{this.Name}"; 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /02.DefiningClasses-Exercises/14.CatLady/Cymric.cs: -------------------------------------------------------------------------------- 1 | namespace CatLady 2 | { 3 | public class Cymric : Cat 4 | { 5 | private double furLength; 6 | 7 | public Cymric(string name, double furLength) 8 | : base(name) 9 | { 10 | this.FurLength = furLength; 11 | } 12 | 13 | public double FurLength 14 | { 15 | get { return this.furLength; } 16 | set { this.furLength = value; } 17 | } 18 | 19 | public override string ToString() 20 | { 21 | return $"{this.GetType().Name} {base.ToString()} {this.FurLength:F2}"; 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /02.DefiningClasses-Exercises/14.CatLady/Siamese.cs: -------------------------------------------------------------------------------- 1 | namespace CatLady 2 | { 3 | public class Siamese : Cat 4 | { 5 | private double earSize; 6 | 7 | public Siamese(string name, double earSize) 8 | : base(name) 9 | { 10 | this.EarSize = earSize; 11 | } 12 | 13 | public double EarSize 14 | { 15 | get { return this.earSize; } 16 | set { this.earSize = value; } 17 | } 18 | 19 | public override string ToString() 20 | { 21 | return $"{this.GetType().Name} {base.ToString()} {this.EarSize}"; 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /02.DefiningClasses-Exercises/14.CatLady/StreetExtraordinaire.cs: -------------------------------------------------------------------------------- 1 | namespace CatLady 2 | { 3 | public class StreetExtraordinaire : Cat 4 | { 5 | private double decibelsOfMeows; 6 | 7 | public StreetExtraordinaire(string name, double decibelsOfMeows) 8 | : base(name) 9 | { 10 | this.DecibelsOfMeows = decibelsOfMeows; 11 | } 12 | 13 | public double DecibelsOfMeows 14 | { 15 | get { return this.decibelsOfMeows; } 16 | set { this.decibelsOfMeows = value; } 17 | } 18 | 19 | public override string ToString() 20 | { 21 | return $"{this.GetType().Name} {base.ToString()} {this.DecibelsOfMeows}"; 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /02.DefiningClasses-Exercises/15.DrawingTool/15.DrawingTool.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /02.DefiningClasses-Exercises/15.DrawingTool/Rectangle.cs: -------------------------------------------------------------------------------- 1 | namespace DrawingTool 2 | { 3 | using System; 4 | 5 | public class Rectangle : Shape 6 | { 7 | private int width; 8 | private int height; 9 | 10 | public Rectangle(int width, int height) 11 | { 12 | this.Width = width; 13 | this.Height = height; 14 | } 15 | 16 | public int Height 17 | { 18 | get { return this.height; } 19 | set { this.height = value; } 20 | } 21 | 22 | public int Width 23 | { 24 | get { return this.width; } 25 | set { this.width = value; } 26 | } 27 | 28 | public override void Draw() 29 | { 30 | Console.WriteLine($"|{new string('-', this.Width)}|"); 31 | for (int i = 0; i < this.Height - 2; i++) 32 | { 33 | Console.WriteLine($"|{new string(' ', this.Width)}|"); 34 | } 35 | Console.WriteLine($"|{new string('-', this.Width)}|"); 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /02.DefiningClasses-Exercises/15.DrawingTool/Shape.cs: -------------------------------------------------------------------------------- 1 | namespace DrawingTool 2 | { 3 | public abstract class Shape 4 | { 5 | public abstract void Draw(); 6 | } 7 | } -------------------------------------------------------------------------------- /02.DefiningClasses-Exercises/15.DrawingTool/Square.cs: -------------------------------------------------------------------------------- 1 | namespace DrawingTool 2 | { 3 | using System; 4 | 5 | public class Square : Shape 6 | { 7 | private int size; 8 | 9 | public Square(int size) 10 | { 11 | this.Size = size; 12 | } 13 | 14 | public int Size 15 | { 16 | get { return this.size; } 17 | set { this.size = value; } 18 | } 19 | 20 | public override void Draw() 21 | { 22 | Console.WriteLine($"|{new string('-', this.Size)}|"); 23 | for (int i = 0; i < this.Size - 2; i++) 24 | { 25 | Console.WriteLine($"|{new string(' ', this.Size)}|"); 26 | } 27 | Console.WriteLine($"|{new string('-', this.Size)}|"); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /02.DefiningClasses-Exercises/15.DrawingTool/Startup.cs: -------------------------------------------------------------------------------- 1 | namespace DrawingTool 2 | { 3 | using System; 4 | 5 | public class Startup 6 | { 7 | public static void Main() 8 | { 9 | string input = Console.ReadLine(); 10 | switch (input) 11 | { 12 | case "Square": 13 | int size = int.Parse(Console.ReadLine()); 14 | Square square = new Square(size); 15 | square.Draw(); 16 | break; 17 | case "Rectangle": 18 | int width = int.Parse(Console.ReadLine()); 19 | int height = int.Parse(Console.ReadLine()); 20 | Rectangle rectangle = new Rectangle(width, height); 21 | rectangle.Draw(); 22 | break; 23 | } 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /03.WorkingWithAbstraction-Lab/01.RhombusOfStars/01.RhombusOfStars.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /03.WorkingWithAbstraction-Lab/01.RhombusOfStars/Startup.cs: -------------------------------------------------------------------------------- 1 | namespace RhombusOfStars 2 | { 3 | using System; 4 | 5 | public class Startup 6 | { 7 | public static void Main() 8 | { 9 | int number = int.Parse(Console.ReadLine()); 10 | 11 | for (int i = 1; i <= number; i++) 12 | { 13 | PrintRow(number, i); 14 | } 15 | 16 | for (int i = number - 1; i >= 1; i--) 17 | { 18 | PrintRow(number, i); 19 | } 20 | } 21 | 22 | private static void PrintRow(int number, int i) 23 | { 24 | Console.Write(new string(' ', number - i)); 25 | Console.Write("*"); 26 | for (int j = 1; j < i; j++) 27 | { 28 | Console.Write(" *"); 29 | } 30 | Console.WriteLine(); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /03.WorkingWithAbstraction-Lab/02.PointInRectangle/02.PointInRectangle.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /03.WorkingWithAbstraction-Lab/02.PointInRectangle/Point.cs: -------------------------------------------------------------------------------- 1 | namespace PointInRectangle 2 | { 3 | public class Point 4 | { 5 | public Point(int x, int y) 6 | { 7 | this.X = x; 8 | this.Y = y; 9 | } 10 | 11 | public int X { get; set; } 12 | 13 | public int Y { get; set; } 14 | } 15 | } -------------------------------------------------------------------------------- /03.WorkingWithAbstraction-Lab/02.PointInRectangle/Rectangle.cs: -------------------------------------------------------------------------------- 1 | namespace PointInRectangle 2 | { 3 | using System; 4 | 5 | public class Rectangle 6 | { 7 | public Rectangle(int topLeftX, int topLeftY, int bottomRightX, int bottomRightY) 8 | { 9 | this.TopLeftX = topLeftX; 10 | this.TopLeftY = topLeftY; 11 | this.BottomRightX = bottomRightX; 12 | this.BottomRightY = bottomRightY; 13 | } 14 | 15 | public int TopLeftX { get; set; } 16 | 17 | public int TopLeftY { get; set; } 18 | 19 | public int BottomRightX { get; set; } 20 | 21 | public int BottomRightY { get; set; } 22 | 23 | public void Contains(Point point) 24 | { 25 | bool isContains = this.TopLeftX <= point.X && point.X <= this.BottomRightX && this.TopLeftY <= point.Y && point.Y <= this.BottomRightY; 26 | Console.WriteLine(isContains); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /03.WorkingWithAbstraction-Lab/02.PointInRectangle/Startup.cs: -------------------------------------------------------------------------------- 1 | namespace PointInRectangle 2 | { 3 | using System; 4 | using System.Linq; 5 | 6 | public class Startup 7 | { 8 | public static void Main() 9 | { 10 | int[] inputParts = Console.ReadLine().Split(new []{' '}, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray(); 11 | Rectangle rectangle = new Rectangle(inputParts[0], inputParts[1], inputParts[2], inputParts[3]); 12 | 13 | int number = int.Parse(Console.ReadLine()); 14 | for (int i = 0; i < number; i++) 15 | { 16 | inputParts = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray(); 17 | Point point = new Point(inputParts[0], inputParts[1]); 18 | rectangle.Contains(point); 19 | } 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /03.WorkingWithAbstraction-Lab/03.StudentSystem/03.StudentSystem.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /03.WorkingWithAbstraction-Lab/03.StudentSystem/Startup.cs: -------------------------------------------------------------------------------- 1 | namespace StudentSystem 2 | { 3 | using System; 4 | 5 | public class Startup 6 | { 7 | public static void Main() 8 | { 9 | StudentSystem studentSystem = new StudentSystem(); 10 | string input = Console.ReadLine(); 11 | while (input != "Exit") 12 | { 13 | studentSystem.ParseCommand(input); 14 | input = Console.ReadLine(); 15 | } 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /03.WorkingWithAbstraction-Lab/04.HotelReservation/04.HotelReservation.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /03.WorkingWithAbstraction-Lab/04.HotelReservation/Enums/DiscountType.cs: -------------------------------------------------------------------------------- 1 | namespace HotelReservation.Enums 2 | { 3 | public enum DiscountType 4 | { 5 | None, 6 | SecondVisit = 10, 7 | VIP = 20, 8 | } 9 | } -------------------------------------------------------------------------------- /03.WorkingWithAbstraction-Lab/04.HotelReservation/Enums/Season.cs: -------------------------------------------------------------------------------- 1 | namespace HotelReservation.Enums 2 | { 3 | public enum Season 4 | { 5 | Autumn = 1, 6 | Sping = 2, 7 | Winter = 3, 8 | Summer = 4, 9 | } 10 | } -------------------------------------------------------------------------------- /03.WorkingWithAbstraction-Lab/04.HotelReservation/Startup.cs: -------------------------------------------------------------------------------- 1 | namespace HotelReservation 2 | { 3 | using System; 4 | 5 | public class Startup 6 | { 7 | public static void Main() 8 | { 9 | string input = Console.ReadLine(); 10 | PriceCalculator calculator = new PriceCalculator(); 11 | calculator.ParseCommand(input); 12 | calculator.CalcualteTotalPrice(); 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /04.WorkingWithAbstraction-Exercises/01.RawData/01.RawData.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /04.WorkingWithAbstraction-Exercises/02.CarSalesman/02.CarSalesman.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /04.WorkingWithAbstraction-Exercises/03.JediGalaxy/03.JediGalaxy.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /04.WorkingWithAbstraction-Exercises/04.Hospital/04.Hospital.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /04.WorkingWithAbstraction-Exercises/05.GreedyTimes/05.GreedyTimes.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /04.WorkingWithAbstraction-Exercises/06.Sneaking/06.Sneaking.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /04.WorkingWithAbstraction-Exercises/07.FamilyTree/07.FamilyTree.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /05.Encapsulation-Lab/01.SortPersonsByNameAndAge/01.SortPersonsByNameAndAge.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /05.Encapsulation-Lab/01.SortPersonsByNameAndAge/Person.cs: -------------------------------------------------------------------------------- 1 | public class Person 2 | { 3 | private string firstName; 4 | private string lastName; 5 | private int age; 6 | 7 | public Person(string firstName, string lastName, int age) 8 | { 9 | this.firstName = firstName; 10 | this.lastName = lastName; 11 | this.age = age; 12 | } 13 | 14 | public int Age 15 | { 16 | get { return this.age; } 17 | } 18 | 19 | public string LastName 20 | { 21 | get { return this.lastName; } 22 | } 23 | 24 | public string FirstName 25 | { 26 | get { return this.firstName; } 27 | } 28 | 29 | public override string ToString() 30 | { 31 | return $"{this.FirstName} {this.LastName} is {this.Age} years old."; 32 | } 33 | } -------------------------------------------------------------------------------- /05.Encapsulation-Lab/01.SortPersonsByNameAndAge/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | public class Startup 6 | { 7 | public static void Main() 8 | { 9 | int lines = int.Parse(Console.ReadLine()); 10 | List persons = new List(); 11 | for (int i = 0; i < lines; i++) 12 | { 13 | string[] cmdArgs = Console.ReadLine().Split(); 14 | Person person = new Person(cmdArgs[0], cmdArgs[1], int.Parse(cmdArgs[2])); 15 | persons.Add(person); 16 | } 17 | 18 | persons.OrderBy(p => p.FirstName) 19 | .ThenBy(p => p.Age) 20 | .ToList() 21 | .ForEach(p => Console.WriteLine(p.ToString())); 22 | } 23 | } -------------------------------------------------------------------------------- /05.Encapsulation-Lab/02.SalaryIncrease/02.SalaryIncrease.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /05.Encapsulation-Lab/02.SalaryIncrease/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | public class Startup 5 | { 6 | public static void Main() 7 | { 8 | int lines = int.Parse(Console.ReadLine()); 9 | List persons = new List(); 10 | for (int i = 0; i < lines; i++) 11 | { 12 | string[] cmdArgs = Console.ReadLine().Split(); 13 | Person person = new Person(cmdArgs[0], cmdArgs[1], int.Parse(cmdArgs[2]), double.Parse(cmdArgs[3])); 14 | persons.Add(person); 15 | } 16 | double bonus = double.Parse(Console.ReadLine()); 17 | persons.ForEach(p => p.IncreaseSalary(bonus)); 18 | persons.ForEach(p => Console.WriteLine(p.ToString())); 19 | } 20 | } -------------------------------------------------------------------------------- /05.Encapsulation-Lab/03.ValidationData/03.ValidationData.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /05.Encapsulation-Lab/03.ValidationData/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | public class Startup 5 | { 6 | public static void Main() 7 | { 8 | int lines = int.Parse(Console.ReadLine()); 9 | List persons = new List(); 10 | for (int i = 0; i < lines; i++) 11 | { 12 | string[] cmdArgs = Console.ReadLine().Split(); 13 | try 14 | { 15 | Person person = new Person(cmdArgs[0], cmdArgs[1], int.Parse(cmdArgs[2]), double.Parse(cmdArgs[3])); 16 | persons.Add(person); 17 | } 18 | catch (ArgumentException ae) 19 | { 20 | Console.WriteLine(ae.Message); 21 | } 22 | } 23 | double bonus = double.Parse(Console.ReadLine()); 24 | persons.ForEach(p => p.IncreaseSalary(bonus)); 25 | persons.ForEach(p => Console.WriteLine(p.ToString())); 26 | } 27 | } -------------------------------------------------------------------------------- /05.Encapsulation-Lab/04.FirstAndReserveTeam/04.FirstAndReserveTeam.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /05.Encapsulation-Lab/04.FirstAndReserveTeam/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public class Startup 4 | { 5 | public static void Main() 6 | { 7 | Team team = new Team("SoftUni"); 8 | 9 | int lines = int.Parse(Console.ReadLine()); 10 | for (int i = 0; i < lines; i++) 11 | { 12 | string[] cmdArgs = Console.ReadLine().Split(); 13 | try 14 | { 15 | Person person = new Person(cmdArgs[0], cmdArgs[1], int.Parse(cmdArgs[2]), decimal.Parse(cmdArgs[3])); 16 | team.AddPlayer(person); 17 | } 18 | catch (ArgumentException ae) 19 | { 20 | Console.WriteLine(ae.Message); 21 | } 22 | } 23 | 24 | Console.WriteLine(team); 25 | } 26 | } -------------------------------------------------------------------------------- /06.Encapsulation-Exercises/01.ClassBox/01.ClassBox.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /06.Encapsulation-Exercises/01.ClassBox/Startup.cs: -------------------------------------------------------------------------------- 1 | namespace ClassBox 2 | { 3 | using System; 4 | 5 | public class Startup 6 | { 7 | public static void Main() 8 | { 9 | double length = double.Parse(Console.ReadLine()); 10 | double width = double.Parse(Console.ReadLine()); 11 | double height = double.Parse(Console.ReadLine()); 12 | 13 | Box box = new Box(length, width, height); 14 | box.CalculateSurfaceArea(); 15 | box.CalculateLateralArea(); 16 | box.CalculateVolume(); 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /06.Encapsulation-Exercises/02.ClassBoxDataValidation/02.ClassBoxDataValidation.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /06.Encapsulation-Exercises/02.ClassBoxDataValidation/Startup.cs: -------------------------------------------------------------------------------- 1 | namespace ClassBoxDataValidation 2 | { 3 | using System; 4 | 5 | public class Startup 6 | { 7 | public static void Main() 8 | { 9 | double length = double.Parse(Console.ReadLine()); 10 | double width = double.Parse(Console.ReadLine()); 11 | double height = double.Parse(Console.ReadLine()); 12 | 13 | try 14 | { 15 | Box box = new Box(length, width, height); 16 | box.CalculateSurfaceArea(); 17 | box.CalculateLateralArea(); 18 | box.CalculateVolume(); 19 | } 20 | catch (ArgumentException ae) 21 | { 22 | Console.WriteLine(ae.Message); 23 | } 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /06.Encapsulation-Exercises/03.AnimalFarm/03.AnimalFarm.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /06.Encapsulation-Exercises/03.AnimalFarm/Startup.cs: -------------------------------------------------------------------------------- 1 | namespace AnimalFarm 2 | { 3 | using System; 4 | 5 | public class Startup 6 | { 7 | public static void Main(string[] args) 8 | { 9 | string name = Console.ReadLine(); 10 | int age = int.Parse(Console.ReadLine()); 11 | 12 | try 13 | { 14 | Chicken chicken = new Chicken(name, age); 15 | Console.WriteLine( 16 | "Chicken {0} (age {1}) can produce {2} eggs per day.", 17 | chicken.Name, 18 | chicken.Age, 19 | chicken.GetProductPerDay()); 20 | } 21 | catch (ArgumentException exception) 22 | { 23 | Console.WriteLine(exception.Message); 24 | } 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /06.Encapsulation-Exercises/04.ShoppingSpree/04.ShoppingSpree.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /06.Encapsulation-Exercises/05.PizzaCalories/05.PizzaCalories.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /06.Encapsulation-Exercises/06.FootballTeamGenerator/06.FootballTeamGenerator.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /07.Inheritance-Lab/01.SingleInheritance/01.SingleInheritance.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /07.Inheritance-Lab/01.SingleInheritance/Animal.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public class Animal 4 | { 5 | public void Eat() 6 | { 7 | Console.WriteLine("eating..."); 8 | } 9 | } -------------------------------------------------------------------------------- /07.Inheritance-Lab/01.SingleInheritance/Dog.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public class Dog : Animal 4 | { 5 | public void Bark() 6 | { 7 | Console.WriteLine("barking..."); 8 | } 9 | } -------------------------------------------------------------------------------- /07.Inheritance-Lab/01.SingleInheritance/Startup.cs: -------------------------------------------------------------------------------- 1 | public class Startup 2 | { 3 | public static void Main() 4 | { 5 | Dog dog = new Dog(); 6 | dog.Eat(); 7 | dog.Bark(); 8 | } 9 | } -------------------------------------------------------------------------------- /07.Inheritance-Lab/02.MultiplyInheritance/02.MultiplyInheritance.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /07.Inheritance-Lab/02.MultiplyInheritance/Animal.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public class Animal 4 | { 5 | public void Eat() 6 | { 7 | Console.WriteLine("eating..."); 8 | } 9 | } -------------------------------------------------------------------------------- /07.Inheritance-Lab/02.MultiplyInheritance/Dog.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public class Dog : Animal 4 | { 5 | public void Bark() 6 | { 7 | Console.WriteLine("barking..."); 8 | } 9 | } -------------------------------------------------------------------------------- /07.Inheritance-Lab/02.MultiplyInheritance/Puppy.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public class Puppy : Dog 4 | { 5 | public void Weep() 6 | { 7 | Console.WriteLine("weeping..."); 8 | } 9 | } -------------------------------------------------------------------------------- /07.Inheritance-Lab/02.MultiplyInheritance/Startup.cs: -------------------------------------------------------------------------------- 1 | public class Startup 2 | { 3 | public static void Main() 4 | { 5 | Puppy puppy = new Puppy(); 6 | puppy.Eat(); 7 | puppy.Bark(); 8 | puppy.Weep(); 9 | } 10 | } -------------------------------------------------------------------------------- /07.Inheritance-Lab/03.HierarchicalInheritance/03.HierarchicalInheritance.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /07.Inheritance-Lab/03.HierarchicalInheritance/Animal.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public class Animal 4 | { 5 | public void Eat() 6 | { 7 | Console.WriteLine("eating..."); 8 | } 9 | } -------------------------------------------------------------------------------- /07.Inheritance-Lab/03.HierarchicalInheritance/Cat.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public class Cat : Animal 4 | { 5 | public void Meow() 6 | { 7 | Console.WriteLine("meowing..."); 8 | } 9 | } -------------------------------------------------------------------------------- /07.Inheritance-Lab/03.HierarchicalInheritance/Dog.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public class Dog : Animal 4 | { 5 | public void Bark() 6 | { 7 | Console.WriteLine("barking..."); 8 | } 9 | } -------------------------------------------------------------------------------- /07.Inheritance-Lab/03.HierarchicalInheritance/Startup.cs: -------------------------------------------------------------------------------- 1 | public class Startup 2 | { 3 | public static void Main() 4 | { 5 | Dog dog = new Dog(); 6 | dog.Eat(); 7 | dog.Bark(); 8 | 9 | Cat cat = new Cat(); 10 | cat.Eat(); 11 | cat.Meow(); 12 | } 13 | } -------------------------------------------------------------------------------- /07.Inheritance-Lab/04.RandomList/04.RandomList.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /07.Inheritance-Lab/04.RandomList/RandomList.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | public class RandomList : List 5 | { 6 | private Random random; 7 | 8 | public RandomList() 9 | { 10 | this.random = new Random(); 11 | } 12 | 13 | public string RandomString() 14 | { 15 | return ""; 16 | } 17 | } -------------------------------------------------------------------------------- /07.Inheritance-Lab/04.RandomList/Startup.cs: -------------------------------------------------------------------------------- 1 | public class Startup 2 | { 3 | public static void Main() 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /07.Inheritance-Lab/05.StackOfStrings/05.StackOfStrings.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /07.Inheritance-Lab/05.StackOfStrings/StackOfStrings.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | 4 | public class StackOfStrings 5 | { 6 | private List data; 7 | 8 | public StackOfStrings() 9 | { 10 | this.data = new List(); 11 | } 12 | 13 | public void Push(string item) 14 | { 15 | this.data.Add(item); 16 | } 17 | 18 | public string Pop() 19 | { 20 | string lastElement = this.data.Last(); 21 | this.data.Remove(lastElement); 22 | return lastElement; 23 | } 24 | 25 | public string Peek() 26 | { 27 | string lastElement = this.data.Last(); 28 | return lastElement; 29 | } 30 | 31 | public bool IsEmpty() 32 | { 33 | return this.data.Count == 0; 34 | } 35 | } -------------------------------------------------------------------------------- /07.Inheritance-Lab/05.StackOfStrings/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public class Startup 4 | { 5 | public static void Main() 6 | { 7 | StackOfStrings stack = new StackOfStrings(); 8 | stack.Push("Pesho"); 9 | stack.Push("Ivan"); 10 | stack.Push("Gosho"); 11 | 12 | Console.WriteLine(stack.Peek()); 13 | Console.WriteLine(stack.IsEmpty()); 14 | stack.Pop(); 15 | stack.Pop(); 16 | stack.Pop(); 17 | Console.WriteLine(stack.IsEmpty()); 18 | } 19 | } -------------------------------------------------------------------------------- /08.Inheritance-Exercises/01.Person/01.Person.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /08.Inheritance-Exercises/01.Person/Child.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public class Child : Person 4 | { 5 | public Child(string name, int age) 6 | : base(name, age) 7 | { 8 | } 9 | 10 | public override int Age 11 | { 12 | get { return base.Age; } 13 | set 14 | { 15 | if (value > 15) 16 | { 17 | throw new ArgumentException("Child's age must be less than 15!"); 18 | } 19 | base.Age = value; 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /08.Inheritance-Exercises/01.Person/Person.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public class Person 4 | { 5 | private string name; 6 | private int age; 7 | 8 | public Person(string name, int age) 9 | { 10 | this.Name = name; 11 | this.Age = age; 12 | } 13 | 14 | public virtual int Age 15 | { 16 | get { return this.age; } 17 | set 18 | { 19 | if (value < 0) 20 | { 21 | throw new ArgumentException("Age must be positive!"); 22 | } 23 | this.age = value; 24 | } 25 | } 26 | 27 | public string Name 28 | { 29 | get { return this.name; } 30 | set 31 | { 32 | if (value.Length < 3) 33 | { 34 | throw new ArgumentException("Name's length should not be less than 3 symbols!"); 35 | } 36 | this.name = value; 37 | } 38 | } 39 | 40 | public override string ToString() 41 | { 42 | return $"Name: {this.Name}, Age: {this.Age}"; 43 | } 44 | } -------------------------------------------------------------------------------- /08.Inheritance-Exercises/01.Person/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public class Startup 4 | { 5 | public static void Main() 6 | { 7 | string name = Console.ReadLine(); 8 | int age = int.Parse(Console.ReadLine()); 9 | 10 | try 11 | { 12 | Child child = new Child(name, age); 13 | Console.WriteLine(child); 14 | } 15 | catch (ArgumentException ae) 16 | { 17 | Console.WriteLine(ae.Message); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /08.Inheritance-Exercises/02.BookShop/02.BookShop.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /08.Inheritance-Exercises/02.BookShop/GoldenEditionBook.cs: -------------------------------------------------------------------------------- 1 | public class GoldenEditionBook : Book 2 | { 3 | private const int Percentage = 30; 4 | 5 | public GoldenEditionBook(string title, string author, decimal price) 6 | : base(title, author, price) 7 | { 8 | } 9 | 10 | public override decimal Price 11 | { 12 | get { return this.CalculatePrice(); } 13 | } 14 | 15 | private decimal CalculatePrice() 16 | { 17 | decimal price = (base.Price * Percentage / 100) + base.Price; 18 | return price; 19 | } 20 | } -------------------------------------------------------------------------------- /08.Inheritance-Exercises/02.BookShop/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public class Startup 4 | { 5 | public static void Main() 6 | { 7 | try 8 | { 9 | string author = Console.ReadLine(); 10 | string title = Console.ReadLine(); 11 | decimal price = decimal.Parse(Console.ReadLine()); 12 | 13 | Book book = new Book(title, author, price); 14 | GoldenEditionBook goldenEditionBook = new GoldenEditionBook(title, author, price); 15 | 16 | Console.WriteLine(book); 17 | Console.WriteLine(); 18 | Console.WriteLine(goldenEditionBook); 19 | } 20 | catch (ArgumentException ae) 21 | { 22 | Console.WriteLine(ae.Message); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /08.Inheritance-Exercises/03.Mankind/03.Mankind.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /08.Inheritance-Exercises/03.Mankind/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public class Startup 4 | { 5 | public static void Main() 6 | { 7 | string[] firstInput = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); 8 | string[] secondInput = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); 9 | 10 | try 11 | { 12 | Student student = new Student(firstInput[0], firstInput[1], firstInput[2]); 13 | Worker worker = new Worker(secondInput[0], secondInput[1], double.Parse(secondInput[2]), double.Parse(secondInput[3])); 14 | 15 | Console.WriteLine(student); 16 | Console.WriteLine(); 17 | Console.WriteLine(worker); 18 | } 19 | catch (ArgumentException ae) 20 | { 21 | Console.WriteLine(ae.Message); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /08.Inheritance-Exercises/03.Mankind/Student.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Text; 4 | 5 | public class Student : Human 6 | { 7 | private string facultyNumber; 8 | 9 | public Student(string firstName, string lastName, string facultyNumber) 10 | : base(firstName, lastName) 11 | { 12 | this.FacultyNumber = facultyNumber; 13 | } 14 | 15 | public string FacultyNumber 16 | { 17 | get { return this.facultyNumber; } 18 | set 19 | { 20 | if (value.Length < 5 || value.Length > 10 || !value.All(Char.IsLetterOrDigit)) 21 | { 22 | throw new ArgumentException($"Invalid faculty number!"); 23 | } 24 | this.facultyNumber = value; 25 | } 26 | } 27 | 28 | public override string ToString() 29 | { 30 | StringBuilder sb = new StringBuilder(); 31 | sb.AppendLine(base.ToString()) 32 | .Append($"Faculty number: {this.FacultyNumber}"); 33 | return sb.ToString(); 34 | } 35 | } -------------------------------------------------------------------------------- /08.Inheritance-Exercises/04.OnlineRadioDatabase/04.OnlineRadioDatabase.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /08.Inheritance-Exercises/04.OnlineRadioDatabase/Exceptions/InvalidArtistNameException.cs: -------------------------------------------------------------------------------- 1 | public class InvalidArtistNameException : InvalidSongException 2 | { 3 | public override string Message 4 | { 5 | get { return "Artist name should be between 3 and 20 symbols."; } 6 | } 7 | } -------------------------------------------------------------------------------- /08.Inheritance-Exercises/04.OnlineRadioDatabase/Exceptions/InvalidSongException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public class InvalidSongException : Exception 4 | { 5 | public override string Message 6 | { 7 | get { return "Invalid song."; } 8 | } 9 | } -------------------------------------------------------------------------------- /08.Inheritance-Exercises/04.OnlineRadioDatabase/Exceptions/InvalidSongLengthException.cs: -------------------------------------------------------------------------------- 1 | public class InvalidSongLengthException : InvalidSongException 2 | { 3 | public override string Message 4 | { 5 | get { return "Invalid song length."; } 6 | } 7 | } -------------------------------------------------------------------------------- /08.Inheritance-Exercises/04.OnlineRadioDatabase/Exceptions/InvalidSongMinutesException.cs: -------------------------------------------------------------------------------- 1 | public class InvalidSongMinutesException : InvalidSongLengthException 2 | { 3 | public override string Message 4 | { 5 | get { return "Song minutes should be between 0 and 14."; } 6 | } 7 | } -------------------------------------------------------------------------------- /08.Inheritance-Exercises/04.OnlineRadioDatabase/Exceptions/InvalidSongNameException.cs: -------------------------------------------------------------------------------- 1 | public class InvalidSongNameException : InvalidSongException 2 | { 3 | public override string Message 4 | { 5 | get { return "Song name should be between 3 and 30 symbols."; } 6 | } 7 | } -------------------------------------------------------------------------------- /08.Inheritance-Exercises/04.OnlineRadioDatabase/Exceptions/InvalidSongSecondsException.cs: -------------------------------------------------------------------------------- 1 | public class InvalidSongSecondsException : InvalidSongLengthException 2 | { 3 | public override string Message 4 | { 5 | get { return "Song seconds should be between 0 and 59."; } 6 | } 7 | } -------------------------------------------------------------------------------- /08.Inheritance-Exercises/05.MordorsCruelPlan/05.MordorsCruelPlan.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /08.Inheritance-Exercises/05.MordorsCruelPlan/Factories/FoodFactory.cs: -------------------------------------------------------------------------------- 1 | public class FoodFactory 2 | { 3 | public static Food GetFood(string foodName) 4 | { 5 | switch (foodName.ToLower()) 6 | { 7 | case "apple": 8 | return new Apple(1); 9 | case "cram": 10 | return new Cram(2); 11 | case "honeycake": 12 | return new HoneyCake(5); 13 | case "lembas": 14 | return new Lembas(3); 15 | case "melon": 16 | return new Melon(1); 17 | case "mushrooms": 18 | return new Mushrooms(-10); 19 | default: 20 | return new OtherFood(-1); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /08.Inheritance-Exercises/05.MordorsCruelPlan/Factories/MoodFactory.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | 4 | public class MoodFactory 5 | { 6 | public static Mood GetMood(List foods) 7 | { 8 | int totalPoints = foods.Sum(f => f.PointsOfHappiness); 9 | if (totalPoints < -5) 10 | { 11 | return new Angry(); 12 | } 13 | else if (totalPoints >= -5 && totalPoints <= 0) 14 | { 15 | return new Sad(); 16 | } 17 | else if (totalPoints >= 1 && totalPoints < 15) 18 | { 19 | return new Happy(); 20 | } 21 | else 22 | { 23 | return new JavaScript(); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /08.Inheritance-Exercises/05.MordorsCruelPlan/Foods/Apple.cs: -------------------------------------------------------------------------------- 1 | public class Apple : Food 2 | { 3 | public Apple(int pointsOfHappiness) : base(pointsOfHappiness) 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /08.Inheritance-Exercises/05.MordorsCruelPlan/Foods/Cram.cs: -------------------------------------------------------------------------------- 1 | public class Cram : Food 2 | { 3 | public Cram(int pointsOfHappiness) : base(pointsOfHappiness) 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /08.Inheritance-Exercises/05.MordorsCruelPlan/Foods/Food.cs: -------------------------------------------------------------------------------- 1 | public abstract class Food 2 | { 3 | protected Food(int pointsOfHappiness) 4 | { 5 | this.PointsOfHappiness = pointsOfHappiness; 6 | } 7 | 8 | public int PointsOfHappiness { get; set; } 9 | } -------------------------------------------------------------------------------- /08.Inheritance-Exercises/05.MordorsCruelPlan/Foods/HoneyCake.cs: -------------------------------------------------------------------------------- 1 | public class HoneyCake : Food 2 | { 3 | public HoneyCake(int pointsOfHappiness) : base(pointsOfHappiness) 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /08.Inheritance-Exercises/05.MordorsCruelPlan/Foods/Lembas.cs: -------------------------------------------------------------------------------- 1 | public class Lembas : Food 2 | { 3 | public Lembas(int pointsOfHappiness) : base(pointsOfHappiness) 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /08.Inheritance-Exercises/05.MordorsCruelPlan/Foods/Melon.cs: -------------------------------------------------------------------------------- 1 | public class Melon : Food 2 | { 3 | public Melon(int pointsOfHappiness) : base(pointsOfHappiness) 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /08.Inheritance-Exercises/05.MordorsCruelPlan/Foods/Mushrooms.cs: -------------------------------------------------------------------------------- 1 | public class Mushrooms : Food 2 | { 3 | public Mushrooms(int pointsOfHappiness) : base(pointsOfHappiness) 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /08.Inheritance-Exercises/05.MordorsCruelPlan/Foods/OtherFood.cs: -------------------------------------------------------------------------------- 1 | public class OtherFood : Food 2 | { 3 | public OtherFood(int pointsOfHappiness) : base(pointsOfHappiness) 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /08.Inheritance-Exercises/05.MordorsCruelPlan/Moods/Angry.cs: -------------------------------------------------------------------------------- 1 | public class Angry : Mood 2 | { 3 | } -------------------------------------------------------------------------------- /08.Inheritance-Exercises/05.MordorsCruelPlan/Moods/Happy.cs: -------------------------------------------------------------------------------- 1 | public class Happy : Mood 2 | { 3 | } -------------------------------------------------------------------------------- /08.Inheritance-Exercises/05.MordorsCruelPlan/Moods/JavaScript.cs: -------------------------------------------------------------------------------- 1 | public class JavaScript : Mood 2 | { 3 | } -------------------------------------------------------------------------------- /08.Inheritance-Exercises/05.MordorsCruelPlan/Moods/Mood.cs: -------------------------------------------------------------------------------- 1 | public abstract class Mood 2 | { 3 | public override string ToString() 4 | { 5 | return $"{this.GetType().Name}"; 6 | } 7 | } -------------------------------------------------------------------------------- /08.Inheritance-Exercises/05.MordorsCruelPlan/Moods/Sad.cs: -------------------------------------------------------------------------------- 1 | public class Sad : Mood 2 | { 3 | } -------------------------------------------------------------------------------- /08.Inheritance-Exercises/05.MordorsCruelPlan/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | public class Startup 6 | { 7 | public static void Main() 8 | { 9 | List foods = new List(); 10 | string[] inputParts = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); 11 | foreach (string foodName in inputParts) 12 | { 13 | Food food = FoodFactory.GetFood(foodName); 14 | foods.Add(food); 15 | } 16 | 17 | Mood mood = MoodFactory.GetMood(foods); 18 | Console.WriteLine(foods.Sum(f => f.PointsOfHappiness)); 19 | Console.WriteLine(mood); 20 | } 21 | } -------------------------------------------------------------------------------- /08.Inheritance-Exercises/06.Animals/06.Animals.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /08.Inheritance-Exercises/06.Animals/Animals/Cat.cs: -------------------------------------------------------------------------------- 1 | public class Cat : Animal 2 | { 3 | public Cat(string name, int age, string gender) : base(name, age, gender) 4 | { 5 | } 6 | 7 | public override string ProduceSound() 8 | { 9 | return "Meow meow"; 10 | } 11 | } -------------------------------------------------------------------------------- /08.Inheritance-Exercises/06.Animals/Animals/Dog.cs: -------------------------------------------------------------------------------- 1 | public class Dog : Animal 2 | { 3 | public Dog(string name, int age, string gender) : base(name, age, gender) 4 | { 5 | } 6 | 7 | public override string ProduceSound() 8 | { 9 | return "Woof!"; 10 | } 11 | } -------------------------------------------------------------------------------- /08.Inheritance-Exercises/06.Animals/Animals/Frog.cs: -------------------------------------------------------------------------------- 1 | public class Frog : Animal 2 | { 3 | public Frog(string name, int age, string gender) : base(name, age, gender) 4 | { 5 | } 6 | 7 | public override string ProduceSound() 8 | { 9 | return "Ribbit"; 10 | } 11 | } -------------------------------------------------------------------------------- /08.Inheritance-Exercises/06.Animals/Animals/Kitten.cs: -------------------------------------------------------------------------------- 1 | public class Kitten : Cat 2 | { 3 | public Kitten(string name, int age) : base(name, age, "Female") 4 | { 5 | } 6 | 7 | public override string ProduceSound() 8 | { 9 | return "Meow"; 10 | } 11 | } -------------------------------------------------------------------------------- /08.Inheritance-Exercises/06.Animals/Animals/Tomcat.cs: -------------------------------------------------------------------------------- 1 | public class Tomcat : Cat 2 | { 3 | public Tomcat(string name, int age) : base(name, age, "Male") 4 | { 5 | } 6 | 7 | public override string ProduceSound() 8 | { 9 | return "MEOW"; 10 | } 11 | } -------------------------------------------------------------------------------- /08.Inheritance-Exercises/06.Animals/Interfaces/IProduceSound.cs: -------------------------------------------------------------------------------- 1 | public interface IProduceSound 2 | { 3 | string ProduceSound(); 4 | } -------------------------------------------------------------------------------- /09.InterfacesAndAbstraction-Lab/01.Shapes/01.Shapes.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /09.InterfacesAndAbstraction-Lab/01.Shapes/Interfaces/IDrawable.cs: -------------------------------------------------------------------------------- 1 | public interface IDrawable 2 | { 3 | void Draw(); 4 | } -------------------------------------------------------------------------------- /09.InterfacesAndAbstraction-Lab/01.Shapes/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public class Startup 4 | { 5 | public static void Main() 6 | { 7 | int radius = int.Parse(Console.ReadLine()); 8 | int width = int.Parse(Console.ReadLine()); 9 | int height = int.Parse(Console.ReadLine()); 10 | 11 | try 12 | { 13 | IDrawable circle = new Circle(radius); 14 | IDrawable rectangle = new Rectangle(width, height); 15 | circle.Draw(); 16 | rectangle.Draw(); 17 | } 18 | catch (ArgumentException ae) 19 | { 20 | Console.WriteLine(ae.Message); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /09.InterfacesAndAbstraction-Lab/02.Cars/02.Cars.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /09.InterfacesAndAbstraction-Lab/02.Cars/Cars/Seat.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | 3 | public class Seat : ICar 4 | { 5 | public Seat(string model, string color) 6 | { 7 | this.Model = model; 8 | this.Color = color; 9 | } 10 | 11 | public string Model { get; } 12 | 13 | public string Color { get; } 14 | 15 | public string Start() 16 | { 17 | return "Engine start"; 18 | } 19 | 20 | public string Stop() 21 | { 22 | return "Breaaak!"; 23 | } 24 | 25 | public override string ToString() 26 | { 27 | StringBuilder sb = new StringBuilder(); 28 | sb.AppendLine($"{this.Color} {this.GetType().Name} {this.Model}") 29 | .AppendLine(this.Start()) 30 | .Append(this.Stop()); 31 | return sb.ToString(); 32 | } 33 | } -------------------------------------------------------------------------------- /09.InterfacesAndAbstraction-Lab/02.Cars/Cars/Tesla.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | 3 | public class Tesla : ICar, IElectricCar 4 | { 5 | public Tesla(string model, string color, int battery) 6 | { 7 | this.Model = model; 8 | this.Color = color; 9 | this.Battery = battery; 10 | } 11 | 12 | public string Model { get; } 13 | 14 | public string Color { get; } 15 | 16 | public int Battery { get; } 17 | 18 | public string Start() 19 | { 20 | return "Engine start"; 21 | } 22 | 23 | public string Stop() 24 | { 25 | return "Breaaak!"; 26 | } 27 | 28 | public override string ToString() 29 | { 30 | StringBuilder sb = new StringBuilder(); 31 | sb.AppendLine($"{this.Color} {this.GetType().Name} {this.Model} with {this.Battery} Batteries") 32 | .AppendLine(this.Start()) 33 | .Append(this.Stop()); 34 | return sb.ToString(); 35 | } 36 | } -------------------------------------------------------------------------------- /09.InterfacesAndAbstraction-Lab/02.Cars/Interfaces/ICar.cs: -------------------------------------------------------------------------------- 1 | public interface ICar 2 | { 3 | string Model { get; } 4 | 5 | string Color { get; } 6 | 7 | string Start(); 8 | 9 | string Stop(); 10 | } -------------------------------------------------------------------------------- /09.InterfacesAndAbstraction-Lab/02.Cars/Interfaces/IElectricCar.cs: -------------------------------------------------------------------------------- 1 | public interface IElectricCar 2 | { 3 | int Battery { get; } 4 | } -------------------------------------------------------------------------------- /09.InterfacesAndAbstraction-Lab/02.Cars/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public class Startup 4 | { 5 | public static void Main() 6 | { 7 | ICar seat = new Seat("Leon", "Grey"); 8 | ICar tesla = new Tesla("Model 3", "Red", 2); 9 | 10 | Console.WriteLine(seat); 11 | Console.WriteLine(tesla); 12 | } 13 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/01.DefineInterfaceIPerson/01.DefineInterfaceIPerson.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/01.DefineInterfaceIPerson/Citizen.cs: -------------------------------------------------------------------------------- 1 | public class Citizen : IPerson 2 | { 3 | public Citizen(string name, int age) 4 | { 5 | this.Name = name; 6 | this.Age = age; 7 | } 8 | 9 | public string Name { get; set; } 10 | 11 | public int Age { get; set; } 12 | 13 | public void Insert() 14 | { 15 | 16 | } 17 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/01.DefineInterfaceIPerson/Interfaces/IPerson.cs: -------------------------------------------------------------------------------- 1 | public interface IPerson 2 | { 3 | string Name { get; set; } 4 | 5 | int Age { get; set; } 6 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/01.DefineInterfaceIPerson/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | 4 | public class Startup 5 | { 6 | public static void Main() 7 | { 8 | Type personInterface = typeof(Citizen).GetInterface("IPerson"); 9 | PropertyInfo[] properties = personInterface.GetProperties(); 10 | Console.WriteLine(properties.Length); 11 | string name = Console.ReadLine(); 12 | int age = int.Parse(Console.ReadLine()); 13 | IPerson person = new Citizen(name, age); 14 | Citizen citizen = new Citizen(name, age); 15 | Console.WriteLine(person.Name); 16 | Console.WriteLine(person.Age); 17 | } 18 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/02.MultipleImplementation/02.MultipleImplementation.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/02.MultipleImplementation/Citizen.cs: -------------------------------------------------------------------------------- 1 | public class Citizen : IPerson, IIdentifiable, IBirthable 2 | { 3 | public Citizen(string name, int age, string id, string birthdate) 4 | { 5 | this.Name = name; 6 | this.Age = age; 7 | this.Id = id; 8 | this.Birthdate = birthdate; 9 | } 10 | 11 | public string Name { get; set; } 12 | 13 | public int Age { get; set; } 14 | 15 | public string Id { get; set; } 16 | 17 | public string Birthdate { get; set; } 18 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/02.MultipleImplementation/Interfaces/IBirthable.cs: -------------------------------------------------------------------------------- 1 | public interface IBirthable 2 | { 3 | string Birthdate { get; set; } 4 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/02.MultipleImplementation/Interfaces/IIdentifiable.cs: -------------------------------------------------------------------------------- 1 | public interface IIdentifiable 2 | { 3 | string Id { get; set; } 4 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/02.MultipleImplementation/Interfaces/IPerson.cs: -------------------------------------------------------------------------------- 1 | public interface IPerson 2 | { 3 | string Name { get; set; } 4 | 5 | int Age { get; set; } 6 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/02.MultipleImplementation/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | 4 | public class Startup 5 | { 6 | public static void Main() 7 | { 8 | Type identifiableInterface = typeof(Citizen).GetInterface("IIdentifiable"); 9 | Type birthableInterface = typeof(Citizen).GetInterface("IBirthable"); 10 | PropertyInfo[] properties = identifiableInterface.GetProperties(); 11 | Console.WriteLine(properties.Length); 12 | Console.WriteLine(properties[0].PropertyType.Name); 13 | properties = birthableInterface.GetProperties(); 14 | Console.WriteLine(properties.Length); 15 | Console.WriteLine(properties[0].PropertyType.Name); 16 | string name = Console.ReadLine(); 17 | int age = int.Parse(Console.ReadLine()); 18 | string id = Console.ReadLine(); 19 | string birthdate = Console.ReadLine(); 20 | IIdentifiable identifiable = new Citizen(name, age, id, birthdate); 21 | IBirthable birthable = new Citizen(name, age, id, birthdate); 22 | } 23 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/03.Ferrari/03.Ferrari.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/03.Ferrari/Ferrari.cs: -------------------------------------------------------------------------------- 1 | public class Ferrari : ICar 2 | { 3 | public Ferrari(string driver) 4 | { 5 | this.Model = "488-Spider"; 6 | this.Driver = driver; 7 | } 8 | 9 | public string Model { get; } 10 | 11 | public string Driver { get; } 12 | 13 | public string UseBrakes() 14 | { 15 | return "Brakes!"; 16 | } 17 | 18 | public string PushTheGasPedal() 19 | { 20 | return "Zadu6avam sA!"; 21 | } 22 | 23 | public override string ToString() 24 | { 25 | return $"{this.Model}/{this.UseBrakes()}/{this.PushTheGasPedal()}/{this.Driver}"; 26 | } 27 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/03.Ferrari/Interfaces/ICar.cs: -------------------------------------------------------------------------------- 1 | public interface ICar 2 | { 3 | string Model { get; } 4 | 5 | string Driver { get; } 6 | 7 | string UseBrakes(); 8 | 9 | string PushTheGasPedal(); 10 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/03.Ferrari/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public class Startup 4 | { 5 | public static void Main() 6 | { 7 | string driver = Console.ReadLine(); 8 | ICar car = new Ferrari(driver); 9 | Console.WriteLine(car); 10 | 11 | string ferrariName = typeof(Ferrari).Name; 12 | string iCarInterfaceName = typeof(ICar).Name; 13 | 14 | bool isCreated = typeof(ICar).IsInterface; 15 | if (!isCreated) 16 | { 17 | throw new Exception("No interface ICar was created"); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/04.Telephony/04.Telephony.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/04.Telephony/Interfaces/IBrowsable.cs: -------------------------------------------------------------------------------- 1 | public interface IBrowsable 2 | { 3 | string BrowseInWeb(string site); 4 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/04.Telephony/Interfaces/IPhone.cs: -------------------------------------------------------------------------------- 1 | public interface IPhone 2 | { 3 | string Call(string number); 4 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/04.Telephony/Smartphone.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | public class Smartphone : IPhone, IBrowsable 5 | { 6 | public string Call(string number) 7 | { 8 | if (number.All(Char.IsDigit)) 9 | { 10 | return $"Calling... {number}"; 11 | } 12 | else 13 | { 14 | return "Invalid number!"; 15 | } 16 | } 17 | 18 | public string BrowseInWeb(string site) 19 | { 20 | if (site.Any(Char.IsDigit)) 21 | { 22 | return "Invalid URL!"; 23 | } 24 | else 25 | { 26 | return $"Browsing: {site}!"; 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/04.Telephony/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public class Startup 4 | { 5 | public static void Main() 6 | { 7 | string[] phoneNumbers = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); 8 | string[] sites = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); 9 | Smartphone smartphone = new Smartphone(); 10 | 11 | foreach (string number in phoneNumbers) 12 | { 13 | Console.WriteLine(smartphone.Call(number)); 14 | } 15 | if (sites.Length == 0) 16 | { 17 | Console.WriteLine("Browsing: !"); 18 | } 19 | else 20 | { 21 | foreach (string site in sites) 22 | { 23 | Console.WriteLine(smartphone.BrowseInWeb(site)); 24 | } 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/05.BorderControl/05.BorderControl.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/05.BorderControl/Interfaces/ICitizen.cs: -------------------------------------------------------------------------------- 1 | public interface ICitizen 2 | { 3 | string Name { get; } 4 | 5 | int Age { get; } 6 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/05.BorderControl/Interfaces/IId.cs: -------------------------------------------------------------------------------- 1 | public interface IId 2 | { 3 | string Id { get; } 4 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/05.BorderControl/Interfaces/IRobot.cs: -------------------------------------------------------------------------------- 1 | public interface IRobot 2 | { 3 | string Model { get; } 4 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/05.BorderControl/Models/Citizen.cs: -------------------------------------------------------------------------------- 1 | public class Citizen : IId, ICitizen 2 | { 3 | public Citizen(string name, int age, string id) 4 | { 5 | this.Name = name; 6 | this.Age = age; 7 | this.Id = id; 8 | } 9 | 10 | public string Name { get; } 11 | 12 | public int Age { get; } 13 | 14 | public string Id { get; } 15 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/05.BorderControl/Models/Robot.cs: -------------------------------------------------------------------------------- 1 | public class Robot : IId, IRobot 2 | { 3 | public Robot(string model, string id) 4 | { 5 | this.Model = model; 6 | this.Id = id; 7 | } 8 | 9 | public string Model { get; } 10 | 11 | public string Id { get; } 12 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/06.BirthdayCelebrations/06.BirthdayCelebrations.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/06.BirthdayCelebrations/Interfaces/IBirthdate.cs: -------------------------------------------------------------------------------- 1 | public interface IBirthdate 2 | { 3 | string Birthday { get; } 4 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/06.BirthdayCelebrations/Interfaces/ICitizen.cs: -------------------------------------------------------------------------------- 1 | public interface ICitizen 2 | { 3 | string Name { get; } 4 | 5 | int Age { get; } 6 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/06.BirthdayCelebrations/Interfaces/IId.cs: -------------------------------------------------------------------------------- 1 | public interface IId 2 | { 3 | string Id { get; } 4 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/06.BirthdayCelebrations/Interfaces/IPet.cs: -------------------------------------------------------------------------------- 1 | public interface IPet 2 | { 3 | string Name { get; } 4 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/06.BirthdayCelebrations/Interfaces/IRobot.cs: -------------------------------------------------------------------------------- 1 | public interface IRobot 2 | { 3 | string Model { get; } 4 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/06.BirthdayCelebrations/Models/Citizen.cs: -------------------------------------------------------------------------------- 1 | public class Citizen : IId, ICitizen, IBirthdate 2 | { 3 | public Citizen(string name, int age, string id, string birthday) 4 | { 5 | this.Name = name; 6 | this.Age = age; 7 | this.Id = id; 8 | this.Birthday = birthday; 9 | } 10 | 11 | public string Name { get; } 12 | 13 | public int Age { get; } 14 | 15 | public string Id { get; } 16 | 17 | public string Birthday { get; } 18 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/06.BirthdayCelebrations/Models/Pet.cs: -------------------------------------------------------------------------------- 1 | public class Pet : IPet, IBirthdate 2 | { 3 | public Pet(string name, string birthday) 4 | { 5 | this.Name = name; 6 | this.Birthday = birthday; 7 | } 8 | 9 | public string Name { get; } 10 | 11 | public string Birthday { get; } 12 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/06.BirthdayCelebrations/Models/Robot.cs: -------------------------------------------------------------------------------- 1 | public class Robot : IId, IRobot 2 | { 3 | public Robot(string model, string id) 4 | { 5 | this.Model = model; 6 | this.Id = id; 7 | } 8 | 9 | public string Model { get; } 10 | 11 | public string Id { get; } 12 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/07.FoodShortage/07.FoodShortage.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/07.FoodShortage/Interfaces/IBirthdate.cs: -------------------------------------------------------------------------------- 1 | public interface IBirthdate 2 | { 3 | string Birthday { get; } 4 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/07.FoodShortage/Interfaces/IBuyer.cs: -------------------------------------------------------------------------------- 1 | public interface IBuyer : ICitizen 2 | { 3 | int Food { get; } 4 | 5 | void BuyFood(); 6 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/07.FoodShortage/Interfaces/ICitizen.cs: -------------------------------------------------------------------------------- 1 | public interface ICitizen 2 | { 3 | string Name { get; } 4 | 5 | int Age { get; } 6 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/07.FoodShortage/Interfaces/IId.cs: -------------------------------------------------------------------------------- 1 | public interface IId 2 | { 3 | string Id { get; } 4 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/07.FoodShortage/Interfaces/IRebel.cs: -------------------------------------------------------------------------------- 1 | public interface IRebel 2 | { 3 | string Group { get; } 4 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/07.FoodShortage/Models/Citizen.cs: -------------------------------------------------------------------------------- 1 | public class Citizen : IId, IBirthdate, IBuyer 2 | { 3 | public Citizen(string name, int age, string id, string birthday) 4 | { 5 | this.Name = name; 6 | this.Age = age; 7 | this.Id = id; 8 | this.Birthday = birthday; 9 | this.Food = 0; 10 | } 11 | 12 | public string Name { get; } 13 | 14 | public int Age { get; } 15 | 16 | public string Id { get; } 17 | 18 | public string Birthday { get; } 19 | 20 | public int Food { get; private set; } 21 | 22 | public void BuyFood() 23 | { 24 | this.Food += 10; 25 | } 26 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/07.FoodShortage/Models/Rebel.cs: -------------------------------------------------------------------------------- 1 | public class Rebel : IRebel, IBuyer 2 | { 3 | public Rebel(string name, int age, string @group) 4 | { 5 | this.Name = name; 6 | this.Age = age; 7 | this.Group = @group; 8 | this.Food = 0; 9 | } 10 | 11 | public string Name { get; } 12 | 13 | public int Age { get; } 14 | 15 | public string Group { get; } 16 | 17 | public int Food { get; private set; } 18 | 19 | public void BuyFood() 20 | { 21 | this.Food += 5; 22 | } 23 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/08.MilitaryElite/08.MilitaryElite.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/08.MilitaryElite/Interfaces/ICommando.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | public interface ICommando : ISpecialisedSoldier 4 | { 5 | List Missions { get; } 6 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/08.MilitaryElite/Interfaces/IEngineer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | public interface IEngineer : ISpecialisedSoldier 4 | { 5 | List Repairs { get; } 6 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/08.MilitaryElite/Interfaces/ILeutenantGeneral.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | public interface ILeutenantGeneral : IPrivate 4 | { 5 | List Privates { get; } 6 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/08.MilitaryElite/Interfaces/IMission.cs: -------------------------------------------------------------------------------- 1 | public interface IMission 2 | { 3 | string CodeName { get; } 4 | 5 | string State { get; } 6 | 7 | void CompleteMission(); 8 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/08.MilitaryElite/Interfaces/IPrivate.cs: -------------------------------------------------------------------------------- 1 | public interface IPrivate : ISoldier 2 | { 3 | double Salary { get; } 4 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/08.MilitaryElite/Interfaces/IRepair.cs: -------------------------------------------------------------------------------- 1 | public interface IRepair 2 | { 3 | string PartName { get; } 4 | 5 | int HoursWorked { get; } 6 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/08.MilitaryElite/Interfaces/ISoldier.cs: -------------------------------------------------------------------------------- 1 | public interface ISoldier 2 | { 3 | int Id { get; } 4 | 5 | string FirstName { get; } 6 | 7 | string LastName { get; } 8 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/08.MilitaryElite/Interfaces/ISpecialisedSoldier.cs: -------------------------------------------------------------------------------- 1 | public interface ISpecialisedSoldier : IPrivate 2 | { 3 | string Corp { get; } 4 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/08.MilitaryElite/Interfaces/ISpy.cs: -------------------------------------------------------------------------------- 1 | public interface ISpy : ISoldier 2 | { 3 | int CodeNumber { get; } 4 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/08.MilitaryElite/Models/Commando.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text; 3 | 4 | public class Commando : SpecialisedSoldier, ICommando 5 | { 6 | public Commando(int id, string firstName, string lastName, double salary, string corp, List missions) 7 | : base(id, firstName, lastName, salary, corp) 8 | { 9 | this.Missions = missions; 10 | } 11 | 12 | public List Missions { get; } 13 | 14 | public override string ToString() 15 | { 16 | StringBuilder sb = new StringBuilder(); 17 | sb.AppendLine(base.ToString()) 18 | .AppendLine("Missions:"); 19 | foreach (IMission mission in Missions) 20 | { 21 | sb.AppendLine($" {mission}"); 22 | } 23 | return sb.ToString().Trim(); 24 | } 25 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/08.MilitaryElite/Models/Engineer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text; 3 | 4 | public class Engineer : SpecialisedSoldier, IEngineer 5 | { 6 | public Engineer(int id, string firstName, string lastName, double salary, string corp, List repairs) 7 | : base(id, firstName, lastName, salary, corp) 8 | { 9 | this.Repairs = repairs; 10 | } 11 | 12 | public List Repairs { get; } 13 | 14 | public override string ToString() 15 | { 16 | StringBuilder sb = new StringBuilder(); 17 | sb.AppendLine(base.ToString()) 18 | .AppendLine("Repairs:"); 19 | foreach (IRepair repair in this.Repairs) 20 | { 21 | sb.AppendLine($" {repair}"); 22 | } 23 | return sb.ToString().Trim(); 24 | } 25 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/08.MilitaryElite/Models/LeutenantGeneral.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text; 3 | 4 | public class LeutenantGeneral : Private, ILeutenantGeneral 5 | { 6 | public LeutenantGeneral(int id, string firstName, string lastName, double salary, List privates) 7 | : base(id, firstName, lastName, salary) 8 | { 9 | this.Privates = privates; 10 | } 11 | 12 | public List Privates { get; } 13 | 14 | public override string ToString() 15 | { 16 | StringBuilder sb = new StringBuilder(); 17 | sb.AppendLine(base.ToString()) 18 | .AppendLine($"Privates:"); 19 | foreach (ISoldier @private in this.Privates) 20 | { 21 | sb.AppendLine($" {@private}"); 22 | } 23 | return sb.ToString().Trim(); 24 | } 25 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/08.MilitaryElite/Models/Mission.cs: -------------------------------------------------------------------------------- 1 | public class Mission : IMission 2 | { 3 | public Mission(string codeName, string state) 4 | { 5 | this.CodeName = codeName; 6 | this.State = state; 7 | } 8 | 9 | public string CodeName { get; } 10 | 11 | public string State { get; private set; } 12 | 13 | public void CompleteMission() 14 | { 15 | this.State = "Finished"; 16 | } 17 | 18 | public override string ToString() 19 | { 20 | return $"Code Name: {this.CodeName} State: {this.State}"; 21 | } 22 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/08.MilitaryElite/Models/Private.cs: -------------------------------------------------------------------------------- 1 | public class Private : Soldier, IPrivate 2 | { 3 | public Private(int id, string firstName, string lastName, double salary) 4 | : base(id, firstName, lastName) 5 | { 6 | this.Salary = salary; 7 | } 8 | 9 | public double Salary { get; } 10 | 11 | public override string ToString() 12 | { 13 | return base.ToString() + $" Salary: {this.Salary:F2}"; 14 | } 15 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/08.MilitaryElite/Models/Repair.cs: -------------------------------------------------------------------------------- 1 | public class Repair : IRepair 2 | { 3 | public Repair(string partName, int hoursWorked) 4 | { 5 | this.PartName = partName; 6 | this.HoursWorked = hoursWorked; 7 | } 8 | 9 | public string PartName { get; } 10 | 11 | public int HoursWorked { get; } 12 | 13 | public override string ToString() 14 | { 15 | return $"Part Name: {this.PartName} Hours Worked: {this.HoursWorked}"; 16 | } 17 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/08.MilitaryElite/Models/Soldier.cs: -------------------------------------------------------------------------------- 1 | public class Soldier : ISoldier 2 | { 3 | public Soldier(int id, string firstName, string lastName) 4 | { 5 | this.Id = id; 6 | this.FirstName = firstName; 7 | this.LastName = lastName; 8 | } 9 | 10 | public int Id { get; } 11 | 12 | public string FirstName { get; } 13 | 14 | public string LastName { get; } 15 | 16 | public override string ToString() 17 | { 18 | return $"Name: {this.FirstName} {this.LastName} Id: {this.Id}"; 19 | } 20 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/08.MilitaryElite/Models/SpecialisedSoldier.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | 3 | public class SpecialisedSoldier : Private, ISpecialisedSoldier 4 | { 5 | public SpecialisedSoldier(int id, string firstName, string lastName, double salary, string corp) 6 | : base(id, firstName, lastName, salary) 7 | { 8 | this.Corp = corp; 9 | } 10 | 11 | public string Corp { get; } 12 | 13 | public override string ToString() 14 | { 15 | StringBuilder sb = new StringBuilder(); 16 | sb.AppendLine(base.ToString()) 17 | .Append($"Corps: {this.Corp}"); 18 | return sb.ToString(); 19 | } 20 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/08.MilitaryElite/Models/Spy.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | 3 | public class Spy : Soldier, ISpy 4 | { 5 | public Spy(int id, string firstName, string lastName, int codeNumber) 6 | : base(id, firstName, lastName) 7 | { 8 | this.CodeNumber = codeNumber; 9 | } 10 | 11 | public int CodeNumber { get; } 12 | 13 | public override string ToString() 14 | { 15 | StringBuilder sb = new StringBuilder(); 16 | sb.AppendLine(base.ToString()) 17 | .Append($"Code Number: {this.CodeNumber}"); 18 | return sb.ToString(); 19 | } 20 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/09.CollectionHierarchy/09.CollectionHierarchy.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/09.CollectionHierarchy/Interfaces/IAddable.cs: -------------------------------------------------------------------------------- 1 | public interface IAddable 2 | { 3 | void Add(string element); 4 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/09.CollectionHierarchy/Interfaces/IMyList.cs: -------------------------------------------------------------------------------- 1 | public interface IMyList : IRemovable 2 | { 3 | int NumberOfElements { get; } 4 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/09.CollectionHierarchy/Interfaces/IRemovable.cs: -------------------------------------------------------------------------------- 1 | public interface IRemovable : IAddable 2 | { 3 | void Remove(); 4 | 5 | void GetRemovedElements(); 6 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/09.CollectionHierarchy/Models/AddCollection.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | public class AddCollection : IAddable 4 | { 5 | private List data; 6 | private List indexes; 7 | 8 | public AddCollection() 9 | { 10 | this.data = new List(); 11 | this.indexes = new List(); 12 | } 13 | 14 | public void Add(string element) 15 | { 16 | int index = this.data.Count; 17 | this.indexes.Add(index); 18 | this.data.Add(element); 19 | } 20 | 21 | public override string ToString() 22 | { 23 | return $"{string.Join(" ", this.indexes)}"; 24 | } 25 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/09.CollectionHierarchy/Models/AddRemoveCollection.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | public class AddRemoveCollection : IRemovable 5 | { 6 | private List data; 7 | private List indexes; 8 | private List removedElements; 9 | 10 | public AddRemoveCollection() 11 | { 12 | this.data = new List(); 13 | this.indexes = new List(); 14 | this.removedElements = new List(); 15 | } 16 | 17 | public void Add(string element) 18 | { 19 | this.indexes.Add(0); 20 | this.data.Insert(0, element); 21 | } 22 | 23 | public void Remove() 24 | { 25 | string lastElement = this.data[this.data.Count - 1]; 26 | this.removedElements.Add(lastElement); 27 | this.data.RemoveAt(this.data.Count - 1); 28 | } 29 | 30 | public void GetRemovedElements() 31 | { 32 | Console.WriteLine($"{string.Join(" ", this.removedElements)}"); 33 | } 34 | 35 | public override string ToString() 36 | { 37 | return $"{string.Join(" ", this.indexes)}"; 38 | } 39 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/09.CollectionHierarchy/Models/MyList.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | public class MyList : IMyList 5 | { 6 | private List data; 7 | private List indexes; 8 | private List removedElements; 9 | 10 | public MyList() 11 | { 12 | this.data = new List(); 13 | this.indexes = new List(); 14 | this.removedElements = new List(); 15 | } 16 | 17 | public int NumberOfElements { get => this.data.Count; } 18 | 19 | public void Add(string element) 20 | { 21 | this.indexes.Add(0); 22 | this.data.Insert(0, element); 23 | } 24 | 25 | public void Remove() 26 | { 27 | string firstElement = this.data[0]; 28 | this.removedElements.Add(firstElement); 29 | this.data.RemoveAt(0); 30 | } 31 | 32 | public void GetRemovedElements() 33 | { 34 | Console.WriteLine($"{string.Join(" ", this.removedElements)}"); 35 | } 36 | 37 | public override string ToString() 38 | { 39 | return $"{string.Join(" ", this.indexes)}"; 40 | } 41 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/10.ExplicitInterfaces/10.ExplicitInterfaces.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/10.ExplicitInterfaces/Citizen.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public class Citizen : IPerson, IResident 4 | { 5 | public Citizen(string name, string country, int age) 6 | { 7 | this.Name = name; 8 | this.Country = country; 9 | this.Age = age; 10 | } 11 | 12 | public string Name { get; } 13 | 14 | public string Country { get; } 15 | 16 | public int Age { get; } 17 | 18 | void IResident.GetName() 19 | { 20 | Console.WriteLine($"Mr/Ms/Mrs {this.Name}"); 21 | } 22 | 23 | void IPerson.GetName() 24 | { 25 | Console.WriteLine($"{this.Name}"); 26 | } 27 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/10.ExplicitInterfaces/Interfaces/IPerson.cs: -------------------------------------------------------------------------------- 1 | public interface IPerson 2 | { 3 | string Name { get; } 4 | 5 | int Age { get; } 6 | 7 | void GetName(); 8 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/10.ExplicitInterfaces/Interfaces/IResident.cs: -------------------------------------------------------------------------------- 1 | public interface IResident 2 | { 3 | string Country { get; } 4 | 5 | void GetName(); 6 | } -------------------------------------------------------------------------------- /10.InterfacesAndAbstraction-Exercises/10.ExplicitInterfaces/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | public class Startup 5 | { 6 | public static void Main() 7 | { 8 | List citizens = new List(); 9 | string input = Console.ReadLine(); 10 | while (input != "End") 11 | { 12 | string[] inputParts = input.Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries); 13 | Citizen citizen = new Citizen(inputParts[0], inputParts[1], int.Parse(inputParts[2])); 14 | citizens.Add(citizen); 15 | input = Console.ReadLine(); 16 | } 17 | 18 | foreach (Citizen citizen in citizens) 19 | { 20 | IPerson person = citizen; 21 | IResident resident = citizen; 22 | person.GetName(); 23 | resident.GetName(); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /11.Polymorphism-Lab/01.MathOperation/01.MathOperation.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /11.Polymorphism-Lab/01.MathOperation/MathOperations.cs: -------------------------------------------------------------------------------- 1 | public class MathOperations 2 | { 3 | public int Add(int a, int b) 4 | { 5 | return a + b; 6 | } 7 | 8 | public double Add(double a, double b, double c) 9 | { 10 | return a + b + c; 11 | } 12 | 13 | public decimal Add(decimal a, decimal b, decimal c) 14 | { 15 | return a + b + c; 16 | } 17 | } -------------------------------------------------------------------------------- /11.Polymorphism-Lab/01.MathOperation/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public class Startup 4 | { 5 | public static void Main() 6 | { 7 | MathOperations mathOperations = new MathOperations(); 8 | Console.WriteLine(mathOperations.Add(2, 3)); 9 | Console.WriteLine(mathOperations.Add(2.2, 3.3, 5.5)); 10 | Console.WriteLine(mathOperations.Add(2.2m, 3.3m, 4.4m)); 11 | } 12 | } -------------------------------------------------------------------------------- /11.Polymorphism-Lab/02.Animals/02.Animals.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /11.Polymorphism-Lab/02.Animals/Models/Animal.cs: -------------------------------------------------------------------------------- 1 | public abstract class Animal 2 | { 3 | protected Animal(string name, string favouriteFood) 4 | { 5 | this.Name = name; 6 | this.FavouriteFood = favouriteFood; 7 | } 8 | 9 | public string Name { get; set; } 10 | 11 | public string FavouriteFood { get; set; } 12 | 13 | public virtual string ExplainMyself() 14 | { 15 | return $"I am {this.Name} and my favourite food is {this.FavouriteFood}"; 16 | } 17 | } -------------------------------------------------------------------------------- /11.Polymorphism-Lab/02.Animals/Models/Cat.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | 3 | public class Cat : Animal 4 | { 5 | public Cat(string name, string favouriteFood) 6 | : base(name, favouriteFood) 7 | { 8 | } 9 | 10 | public override string ExplainMyself() 11 | { 12 | StringBuilder sb = new StringBuilder(); 13 | sb.AppendLine(base.ExplainMyself()) 14 | .Append("MEEOW"); 15 | return sb.ToString(); 16 | } 17 | } -------------------------------------------------------------------------------- /11.Polymorphism-Lab/02.Animals/Models/Dog.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | 3 | public class Dog : Animal 4 | { 5 | public Dog(string name, string favouriteFood) 6 | : base(name, favouriteFood) 7 | { 8 | } 9 | 10 | public override string ExplainMyself() 11 | { 12 | StringBuilder sb = new StringBuilder(); 13 | sb.AppendLine(base.ExplainMyself()) 14 | .Append("DJAAF"); 15 | return sb.ToString(); 16 | } 17 | } -------------------------------------------------------------------------------- /11.Polymorphism-Lab/02.Animals/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public class Startup 4 | { 5 | public static void Main() 6 | { 7 | Animal cat = new Cat("Pesho", "Whiskas"); 8 | Animal dog = new Dog("Gosho", "Meat"); 9 | 10 | Console.WriteLine(cat.ExplainMyself()); 11 | Console.WriteLine(dog.ExplainMyself()); 12 | } 13 | } -------------------------------------------------------------------------------- /11.Polymorphism-Lab/03.Shapes/03.Shapes.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /11.Polymorphism-Lab/03.Shapes/Models/Shape.cs: -------------------------------------------------------------------------------- 1 | public abstract class Shape 2 | { 3 | public abstract double CalculatePerimeter(); 4 | 5 | public abstract double CalculateArea(); 6 | 7 | public virtual string Draw() 8 | { 9 | return "Drawing"; 10 | } 11 | } -------------------------------------------------------------------------------- /11.Polymorphism-Lab/03.Shapes/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public class Startup 4 | { 5 | public static void Main() 6 | { 7 | try 8 | { 9 | Shape circle = new Circle(5); 10 | Shape rectangle = new Rectangle(5, 5); 11 | 12 | Console.WriteLine(circle); 13 | Console.WriteLine(rectangle); 14 | } 15 | catch (ArgumentException ae) 16 | { 17 | Console.WriteLine(ae.Message); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /11.Polymorphism-Lab/03.Shapes/Validators/Validator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public class Validator 4 | { 5 | public static void CheckDimension(double value, string dimension) 6 | { 7 | if (value <= 0) 8 | { 9 | throw new ArgumentException($"{dimension} cannot be zero or negative number!"); 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /12.Polymorphism-Exercises/01.Vehicles/01.Vehicles.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /12.Polymorphism-Exercises/01.Vehicles/Models/Car.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public class Car : Vehicle 4 | { 5 | private const double ACConsumption = 0.9; 6 | 7 | public Car(double fuelQuantity, double fuelConsumption) 8 | : base(fuelQuantity, fuelConsumption) 9 | { 10 | } 11 | 12 | public override void Drive(double distance) 13 | { 14 | double neededFuel = distance * (base.FuelConsumption + ACConsumption); 15 | if (neededFuel <= base.FuelQuantity) 16 | { 17 | base.FuelQuantity -= neededFuel; 18 | Console.WriteLine($"Car travelled {distance} km"); 19 | } 20 | else 21 | { 22 | Console.WriteLine($"Car needs refueling"); 23 | } 24 | } 25 | 26 | public override void Refuel(double liters) 27 | { 28 | base.FuelQuantity += liters; 29 | } 30 | } -------------------------------------------------------------------------------- /12.Polymorphism-Exercises/01.Vehicles/Models/Truck.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public class Truck : Vehicle 4 | { 5 | private const double ACConsumption = 1.6; 6 | private const double UsedFuel = 95; 7 | 8 | public Truck(double fuelQuantity, double fuelConsumption) 9 | : base(fuelQuantity, fuelConsumption) 10 | { 11 | } 12 | 13 | public override void Drive(double distance) 14 | { 15 | double neededFuel = distance * (base.FuelConsumption + ACConsumption); 16 | if (neededFuel <= base.FuelQuantity) 17 | { 18 | base.FuelQuantity -= neededFuel; 19 | Console.WriteLine($"Truck travelled {distance} km"); 20 | } 21 | else 22 | { 23 | Console.WriteLine($"Truck needs refueling"); 24 | } 25 | } 26 | 27 | public override void Refuel(double liters) 28 | { 29 | base.FuelQuantity += (liters * UsedFuel / 100.0); 30 | } 31 | } -------------------------------------------------------------------------------- /12.Polymorphism-Exercises/01.Vehicles/Models/Vehicle.cs: -------------------------------------------------------------------------------- 1 | public abstract class Vehicle 2 | { 3 | private double fuelQuantity; 4 | private double fuelConsumption; 5 | 6 | protected Vehicle(double fuelQuantity, double fuelConsumption) 7 | { 8 | this.FuelQuantity = fuelQuantity; 9 | this.FuelConsumption = fuelConsumption; 10 | } 11 | 12 | public double FuelConsumption 13 | { 14 | get { return this.fuelConsumption; } 15 | set { this.fuelConsumption = value; } 16 | } 17 | 18 | public double FuelQuantity 19 | { 20 | get { return this.fuelQuantity; } 21 | set { this.fuelQuantity = value; } 22 | } 23 | 24 | public abstract void Drive(double distance); 25 | 26 | public abstract void Refuel(double liters); 27 | 28 | public override string ToString() 29 | { 30 | return $"{this.GetType().Name}: {this.FuelQuantity:F2}"; 31 | } 32 | } -------------------------------------------------------------------------------- /12.Polymorphism-Exercises/02.VehiclesExtension/02.VehiclesExtension.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /12.Polymorphism-Exercises/02.VehiclesExtension/Validations/Validator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public class Validator 4 | { 5 | public static void CheckPositiveNumber(double value) 6 | { 7 | if (value < 0) 8 | { 9 | Console.WriteLine("Fuel must be a positive number"); 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /12.Polymorphism-Exercises/03.WildFarm/03.WildFarm.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /12.Polymorphism-Exercises/03.WildFarm/Animals/Animal.cs: -------------------------------------------------------------------------------- 1 | public abstract class Animal 2 | { 3 | private string name; 4 | private double weight; 5 | private int foodEaten; 6 | 7 | protected Animal(string name, double weight) 8 | { 9 | this.Name = name; 10 | this.Weight = weight; 11 | } 12 | 13 | public int FoodEaten 14 | { 15 | get { return this.foodEaten; } 16 | set { this.foodEaten = value; } 17 | } 18 | 19 | public double Weight 20 | { 21 | get { return this.weight; } 22 | set { this.weight = value; } 23 | } 24 | 25 | public string Name 26 | { 27 | get { return this.name; } 28 | set { this.name = value; } 29 | } 30 | 31 | public abstract string MakeSound(); 32 | 33 | public abstract void Eat(Food food); 34 | } -------------------------------------------------------------------------------- /12.Polymorphism-Exercises/03.WildFarm/Animals/Birds/Bird.cs: -------------------------------------------------------------------------------- 1 | public abstract class Bird : Animal 2 | { 3 | private double wingSize; 4 | 5 | protected Bird(string name, double weight, double wingSize) 6 | : base(name, weight) 7 | { 8 | this.wingSize = wingSize; 9 | } 10 | 11 | public double WingSize 12 | { 13 | get { return this.wingSize; } 14 | set { this.wingSize = value; } 15 | } 16 | } -------------------------------------------------------------------------------- /12.Polymorphism-Exercises/03.WildFarm/Animals/Birds/Hen.cs: -------------------------------------------------------------------------------- 1 | public class Hen : Bird 2 | { 3 | private const double HenFoodPiece = 0.35; 4 | 5 | public Hen(string name, double weight, double wingSize) 6 | : base(name, weight, wingSize) 7 | { 8 | } 9 | 10 | public override string MakeSound() 11 | { 12 | return "Cluck"; 13 | } 14 | 15 | public override void Eat(Food food) 16 | { 17 | base.FoodEaten = food.Quantity; 18 | this.Weight += food.Quantity * HenFoodPiece; 19 | } 20 | 21 | public override string ToString() 22 | { 23 | return $"{this.GetType().Name} [{this.Name}, {this.WingSize}, {this.Weight}, {base.FoodEaten}]"; 24 | } 25 | } -------------------------------------------------------------------------------- /12.Polymorphism-Exercises/03.WildFarm/Animals/Birds/Owl.cs: -------------------------------------------------------------------------------- 1 | public class Owl : Bird 2 | { 3 | private const double OwlFoodPiece = 0.25; 4 | 5 | public Owl(string name, double weight, double wingSize) 6 | : base(name, weight, wingSize) 7 | { 8 | } 9 | 10 | public override string MakeSound() 11 | { 12 | return $"Hoot Hoot"; 13 | } 14 | 15 | public override void Eat(Food food) 16 | { 17 | if (food.GetType().Name != "Meat") 18 | { 19 | Validator.GetValidation(this.GetType().Name, food.GetType().Name); 20 | base.FoodEaten = 0; 21 | return; 22 | } 23 | base.FoodEaten = food.Quantity; 24 | this.Weight += food.Quantity * OwlFoodPiece; 25 | } 26 | 27 | public override string ToString() 28 | { 29 | return $"{this.GetType().Name} [{this.Name}, {this.WingSize}, {this.Weight}, {base.FoodEaten}]"; 30 | } 31 | } -------------------------------------------------------------------------------- /12.Polymorphism-Exercises/03.WildFarm/Animals/Mammals/Dog.cs: -------------------------------------------------------------------------------- 1 | public class Dog : Mammal 2 | { 3 | private const double DogFoodPiece = 0.40; 4 | 5 | public Dog(string name, double weight, string livingRegion) 6 | : base(name, weight, livingRegion) 7 | { 8 | } 9 | 10 | public override string MakeSound() 11 | { 12 | return "Woof!"; 13 | } 14 | 15 | public override void Eat(Food food) 16 | { 17 | if (food.GetType().Name != "Meat") 18 | { 19 | Validator.GetValidation(this.GetType().Name, food.GetType().Name); 20 | base.FoodEaten = 0; 21 | return; 22 | } 23 | base.FoodEaten = food.Quantity; 24 | this.Weight += food.Quantity * DogFoodPiece; 25 | } 26 | 27 | public override string ToString() 28 | { 29 | return $"{this.GetType().Name} [{this.Name}, {this.Weight}, {this.LivingRegion}, {base.FoodEaten}]"; 30 | } 31 | } -------------------------------------------------------------------------------- /12.Polymorphism-Exercises/03.WildFarm/Animals/Mammals/Felines/Cat.cs: -------------------------------------------------------------------------------- 1 | public class Cat : Feline 2 | { 3 | private const double CatFoodPiece = 0.30; 4 | 5 | public Cat(string name, double weight, string livingRegion, string breed) 6 | : base(name, weight, livingRegion, breed) 7 | { 8 | } 9 | 10 | public override string MakeSound() 11 | { 12 | return "Meow"; 13 | } 14 | 15 | public override void Eat(Food food) 16 | { 17 | if (food.GetType().Name != "Vegetable" && food.GetType().Name != "Meat") 18 | { 19 | Validator.GetValidation(this.GetType().Name, food.GetType().Name); 20 | base.FoodEaten = 0; 21 | return; 22 | } 23 | base.FoodEaten = food.Quantity; 24 | this.Weight += food.Quantity * CatFoodPiece; 25 | } 26 | 27 | public override string ToString() 28 | { 29 | return $"{this.GetType().Name} [{this.Name}, {this.Breed}, {this.Weight}, {this.LivingRegion}, {base.FoodEaten}]"; 30 | } 31 | } -------------------------------------------------------------------------------- /12.Polymorphism-Exercises/03.WildFarm/Animals/Mammals/Felines/Feline.cs: -------------------------------------------------------------------------------- 1 | public abstract class Feline : Mammal 2 | { 3 | private string breed; 4 | 5 | protected Feline(string name, double weight, string livingRegion, string breed) 6 | : base(name, weight, livingRegion) 7 | { 8 | this.Breed = breed; 9 | } 10 | 11 | public string Breed 12 | { 13 | get { return this.breed; } 14 | set { this.breed = value; } 15 | } 16 | } -------------------------------------------------------------------------------- /12.Polymorphism-Exercises/03.WildFarm/Animals/Mammals/Felines/Tiger.cs: -------------------------------------------------------------------------------- 1 | public class Tiger : Feline 2 | { 3 | private const double TigerFoodPiece = 1.00; 4 | 5 | public Tiger(string name, double weight, string livingRegion, string breed) 6 | : base(name, weight, livingRegion, breed) 7 | { 8 | } 9 | 10 | public override string MakeSound() 11 | { 12 | return "ROAR!!!"; 13 | } 14 | 15 | public override void Eat(Food food) 16 | { 17 | if (food.GetType().Name != "Meat") 18 | { 19 | Validator.GetValidation(this.GetType().Name, food.GetType().Name); 20 | base.FoodEaten = 0; 21 | return; 22 | } 23 | base.FoodEaten = food.Quantity; 24 | this.Weight += food.Quantity * TigerFoodPiece; 25 | } 26 | 27 | public override string ToString() 28 | { 29 | return $"{this.GetType().Name} [{this.Name}, {this.Breed}, {this.Weight}, {this.LivingRegion}, {base.FoodEaten}]"; 30 | } 31 | } -------------------------------------------------------------------------------- /12.Polymorphism-Exercises/03.WildFarm/Animals/Mammals/Mammal.cs: -------------------------------------------------------------------------------- 1 | public abstract class Mammal : Animal 2 | { 3 | private string livingRegion; 4 | 5 | protected Mammal(string name, double weight, string livingRegion) 6 | : base(name, weight) 7 | { 8 | this.LivingRegion = livingRegion; 9 | } 10 | 11 | public string LivingRegion 12 | { 13 | get { return this.livingRegion; } 14 | set { this.livingRegion = value; } 15 | } 16 | } -------------------------------------------------------------------------------- /12.Polymorphism-Exercises/03.WildFarm/Animals/Mammals/Mouse.cs: -------------------------------------------------------------------------------- 1 | public class Mouse : Mammal 2 | { 3 | private const double MouseFoodPiece = 0.10; 4 | 5 | public Mouse(string name, double weight, string livingRegion) 6 | : base(name, weight, livingRegion) 7 | { 8 | } 9 | 10 | public override string MakeSound() 11 | { 12 | return "Squeak"; 13 | } 14 | 15 | public override void Eat(Food food) 16 | { 17 | if (food.GetType().Name != "Vegetable" && food.GetType().Name != "Fruit") 18 | { 19 | Validator.GetValidation(this.GetType().Name, food.GetType().Name); 20 | base.FoodEaten = 0; 21 | return; 22 | } 23 | base.FoodEaten = food.Quantity; 24 | this.Weight += food.Quantity * MouseFoodPiece; 25 | } 26 | 27 | public override string ToString() 28 | { 29 | return $"{this.GetType().Name} [{this.Name}, {this.Weight}, {this.LivingRegion}, {base.FoodEaten}]"; 30 | } 31 | } -------------------------------------------------------------------------------- /12.Polymorphism-Exercises/03.WildFarm/Factories/FoodFactory.cs: -------------------------------------------------------------------------------- 1 | public class FoodFactory 2 | { 3 | public static Food GetFood(string[] foodParts) 4 | { 5 | string foodType = foodParts[0]; 6 | switch (foodType) 7 | { 8 | case "Fruit": 9 | return new Fruit(int.Parse(foodParts[1])); 10 | case "Meat": 11 | return new Meat(int.Parse(foodParts[1])); 12 | case "Seeds": 13 | return new Seeds(int.Parse(foodParts[1])); 14 | case "Vegetable": 15 | return new Vegetable(int.Parse(foodParts[1])); 16 | default: 17 | return null; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /12.Polymorphism-Exercises/03.WildFarm/Food/Food.cs: -------------------------------------------------------------------------------- 1 | public abstract class Food 2 | { 3 | private int quantity; 4 | 5 | protected Food(int quantity) 6 | { 7 | this.Quantity = quantity; 8 | } 9 | 10 | public int Quantity 11 | { 12 | get { return this.quantity; } 13 | set { this.quantity = value; } 14 | } 15 | } -------------------------------------------------------------------------------- /12.Polymorphism-Exercises/03.WildFarm/Food/Fruit.cs: -------------------------------------------------------------------------------- 1 | public class Fruit : Food 2 | { 3 | public Fruit(int quantity) 4 | : base(quantity) 5 | { 6 | } 7 | } -------------------------------------------------------------------------------- /12.Polymorphism-Exercises/03.WildFarm/Food/Meat.cs: -------------------------------------------------------------------------------- 1 | public class Meat : Food 2 | { 3 | public Meat(int quantity) 4 | : base(quantity) 5 | { 6 | } 7 | } -------------------------------------------------------------------------------- /12.Polymorphism-Exercises/03.WildFarm/Food/Seeds.cs: -------------------------------------------------------------------------------- 1 | public class Seeds : Food 2 | { 3 | public Seeds(int quantity) 4 | : base(quantity) 5 | { 6 | } 7 | } -------------------------------------------------------------------------------- /12.Polymorphism-Exercises/03.WildFarm/Food/Vegetable.cs: -------------------------------------------------------------------------------- 1 | public class Vegetable : Food 2 | { 3 | public Vegetable(int quantity) 4 | : base(quantity) 5 | { 6 | } 7 | } -------------------------------------------------------------------------------- /12.Polymorphism-Exercises/03.WildFarm/Validations/Validator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public class Validator 4 | { 5 | public static void GetValidation(string type, string foodType) 6 | { 7 | Console.WriteLine($"{type} does not eat {foodType}!"); 8 | } 9 | } -------------------------------------------------------------------------------- /Exam-07.09.2017-GrandPrix/GrandPrix/Exceptions/ErrorMessage.cs: -------------------------------------------------------------------------------- 1 | public static class ErrorMessage 2 | { 3 | public const string BlownTyre = "Blown Tyre"; 4 | 5 | public const string OutOfFuel = "Out of fuel"; 6 | } -------------------------------------------------------------------------------- /Exam-07.09.2017-GrandPrix/GrandPrix/Factories/CarFactory.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | public class CarFactory 4 | { 5 | public static Car CreateCar(List commandArgs, Tyre tyre) 6 | { 7 | return new Car(int.Parse(commandArgs[0]), double.Parse(commandArgs[1]), tyre); 8 | } 9 | } -------------------------------------------------------------------------------- /Exam-07.09.2017-GrandPrix/GrandPrix/Factories/DriverFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | public class DriverFactory 5 | { 6 | public static Driver CreateDriver(List commandArgs, Car car) 7 | { 8 | string driverType = commandArgs[0]; 9 | switch (driverType) 10 | { 11 | case "Aggressive": 12 | return new AggressiveDriver(commandArgs[1], car); 13 | case "Endurance": 14 | return new EnduranceDriver(commandArgs[1], car); 15 | default: 16 | throw new ArgumentException(); 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /Exam-07.09.2017-GrandPrix/GrandPrix/Factories/TyreFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | public class TyreFactory 5 | { 6 | public static Tyre CreateTyre(List commandArgs) 7 | { 8 | string tyreType = commandArgs[0]; 9 | switch (tyreType) 10 | { 11 | case "Hard": 12 | return new HardTyre(double.Parse(commandArgs[1])); 13 | case "Ultrasoft": 14 | return new UltrasoftTyre(double.Parse(commandArgs[1]), double.Parse(commandArgs[2])); 15 | default: 16 | throw new ArgumentException(); 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /Exam-07.09.2017-GrandPrix/GrandPrix/GrandPrix.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Exam-07.09.2017-GrandPrix/GrandPrix/Models/Drivers/AggressiveDriver.cs: -------------------------------------------------------------------------------- 1 | public class AggressiveDriver : Driver 2 | { 3 | private const double AggressiveDriveFuelConsumption = 2.7; 4 | private const double AggressiveDriverSpeed = 1.3; 5 | 6 | public AggressiveDriver(string name, Car car) 7 | : base(name, car, AggressiveDriveFuelConsumption) 8 | { 9 | } 10 | 11 | public override double Speed => base.Speed * AggressiveDriverSpeed; 12 | } -------------------------------------------------------------------------------- /Exam-07.09.2017-GrandPrix/GrandPrix/Models/Drivers/EnduranceDriver.cs: -------------------------------------------------------------------------------- 1 | public class EnduranceDriver : Driver 2 | { 3 | private const double EnduranceDriverFuelConsumption = 1.5; 4 | 5 | public EnduranceDriver(string name, Car car) 6 | : base(name, car, EnduranceDriverFuelConsumption) 7 | { 8 | } 9 | } -------------------------------------------------------------------------------- /Exam-07.09.2017-GrandPrix/GrandPrix/Models/Track.cs: -------------------------------------------------------------------------------- 1 | public class Track 2 | { 3 | public Track(int totalLaps, int length) 4 | { 5 | this.TotalLaps = totalLaps; 6 | this.Length = length; 7 | this.CurrentLap = 0; 8 | this.Weather = "Sunny"; 9 | } 10 | 11 | public int TotalLaps { get; } 12 | 13 | public int Length { get; } 14 | 15 | public int CurrentLap { get; set; } 16 | 17 | public string Weather { get; set; } 18 | } -------------------------------------------------------------------------------- /Exam-07.09.2017-GrandPrix/GrandPrix/Models/Tyres/HardTyre.cs: -------------------------------------------------------------------------------- 1 | public class HardTyre : Tyre 2 | { 3 | public HardTyre(double hardness) 4 | : base("Hard", hardness) 5 | { 6 | } 7 | } -------------------------------------------------------------------------------- /Exam-07.09.2017-GrandPrix/GrandPrix/Models/Tyres/UltrasoftTyre.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public class UltrasoftTyre : Tyre 4 | { 5 | private double grip; 6 | private double degradation; 7 | 8 | public UltrasoftTyre(double hardness, double grip) 9 | : base("Ultrasoft", hardness) 10 | { 11 | this.Grip = grip; 12 | } 13 | 14 | public double Grip 15 | { 16 | get { return this.grip; } 17 | private set { this.grip = value; } 18 | } 19 | 20 | public override double Degradation 21 | { 22 | get { return this.degradation; } 23 | protected set 24 | { 25 | if (value < 30) 26 | { 27 | throw new ArgumentException(ErrorMessage.BlownTyre); 28 | } 29 | this.degradation = value; 30 | } 31 | } 32 | 33 | public override void ReducedDegradation() 34 | { 35 | this.Degradation -= this.Hardness + this.Grip; 36 | } 37 | } -------------------------------------------------------------------------------- /Exam-07.09.2017-GrandPrix/GrandPrix/Startup.cs: -------------------------------------------------------------------------------- 1 | public class Startup 2 | { 3 | public static void Main() 4 | { 5 | Engine engine = new Engine(); 6 | engine.Run(); 7 | } 8 | } -------------------------------------------------------------------------------- /Exam-11.07.2017-NeedForSpeed/NeedForSpeed/Models/Cars/ShowCar.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | 3 | public class ShowCar : Car 4 | { 5 | private int stars; 6 | 7 | public ShowCar(string brand, string model, int yearOfProduction, int horsepower, int acceleration, int suspension, 8 | int durability) : base(brand, model, yearOfProduction, horsepower, acceleration, suspension, durability) 9 | { 10 | this.Stars = 0; 11 | } 12 | 13 | public int Stars 14 | { 15 | get { return this.stars; } 16 | set { this.stars = value; } 17 | } 18 | 19 | public override void Tune(int tuneIndex, string addOn) 20 | { 21 | base.Tune(tuneIndex, addOn); 22 | this.Stars += tuneIndex; 23 | } 24 | 25 | public override string ToString() 26 | { 27 | StringBuilder sb = new StringBuilder(); 28 | sb.AppendLine(base.ToString()) 29 | .Append($"{this.Stars} *"); 30 | return sb.ToString(); 31 | } 32 | } -------------------------------------------------------------------------------- /Exam-11.07.2017-NeedForSpeed/NeedForSpeed/Models/Garage/Garage.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | public class Garage 4 | { 5 | private List parkedCars; 6 | 7 | public Garage() 8 | { 9 | this.ParkedCars = new List(); 10 | } 11 | 12 | public List ParkedCars 13 | { 14 | get { return this.parkedCars; } 15 | set { this.parkedCars = value; } 16 | } 17 | } -------------------------------------------------------------------------------- /Exam-11.07.2017-NeedForSpeed/NeedForSpeed/Models/Races/CasualRace.cs: -------------------------------------------------------------------------------- 1 | public class CasualRace : Race 2 | { 3 | public CasualRace(int length, string route, int prizePool) 4 | : base(length, route, prizePool) 5 | { 6 | } 7 | 8 | public override int GetPoints(int carId) 9 | { 10 | Car car = this.Participants[carId]; 11 | return (car.Horsepower / car.Acceleration) + (car.Suspension + car.Durability); 12 | } 13 | } -------------------------------------------------------------------------------- /Exam-11.07.2017-NeedForSpeed/NeedForSpeed/Models/Races/DragRace.cs: -------------------------------------------------------------------------------- 1 | public class DragRace : Race 2 | { 3 | public DragRace(int length, string route, int prizePool) 4 | : base(length, route, prizePool) 5 | { 6 | } 7 | 8 | public override int GetPoints(int carId) 9 | { 10 | Car car = this.Participants[carId]; 11 | return car.Horsepower / car.Acceleration; 12 | } 13 | } -------------------------------------------------------------------------------- /Exam-11.07.2017-NeedForSpeed/NeedForSpeed/Models/Races/DriftRace.cs: -------------------------------------------------------------------------------- 1 | public class DriftRace : Race 2 | { 3 | public DriftRace(int length, string route, int prizePool) 4 | : base(length, route, prizePool) 5 | { 6 | } 7 | 8 | public override int GetPoints(int carId) 9 | { 10 | Car car = this.Participants[carId]; 11 | return car.Suspension + car.Durability; 12 | } 13 | } -------------------------------------------------------------------------------- /Exam-11.07.2017-NeedForSpeed/NeedForSpeed/NeedForSpeed.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Exam-11.07.2017-NeedForSpeed/NeedForSpeed/Startup.cs: -------------------------------------------------------------------------------- 1 | public class Startup 2 | { 3 | public static void Main() 4 | { 5 | Engine engine = new Engine(); 6 | engine.Start(); 7 | } 8 | } -------------------------------------------------------------------------------- /Exam-12.07.2017-Avatar/Avatar/Avatar.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Exam-12.07.2017-Avatar/Avatar/Models/Benders/AirBender.cs: -------------------------------------------------------------------------------- 1 | public class AirBender : Bender 2 | { 3 | private double aerialIntegrity; 4 | 5 | public AirBender(string name, int power, double aerialIntegrity) 6 | : base(name, power) 7 | { 8 | this.AerialIntegrity = aerialIntegrity; 9 | } 10 | 11 | public double AerialIntegrity 12 | { 13 | get { return this.aerialIntegrity; } 14 | set { this.aerialIntegrity = value; } 15 | } 16 | 17 | public override double GetBenderPower() 18 | { 19 | return base.Power * this.AerialIntegrity; 20 | } 21 | 22 | public double GetTotalPower() 23 | { 24 | return base.Power * this.AerialIntegrity; 25 | } 26 | 27 | public override string ToString() 28 | { 29 | return $"Air Bender: {this.Name}, Power: {this.Power}, Aerial Integrity: {this.AerialIntegrity:F2}"; 30 | } 31 | } -------------------------------------------------------------------------------- /Exam-12.07.2017-Avatar/Avatar/Models/Benders/Bender.cs: -------------------------------------------------------------------------------- 1 | public abstract class Bender 2 | { 3 | private string name; 4 | private int power; 5 | 6 | protected Bender(string name, int power) 7 | { 8 | this.Name = name; 9 | this.Power = power; 10 | } 11 | 12 | public int Power 13 | { 14 | get { return this.power; } 15 | set { this.power = value; } 16 | } 17 | 18 | public string Name 19 | { 20 | get { return this.name; } 21 | set { this.name = value; } 22 | } 23 | 24 | public abstract double GetBenderPower(); 25 | } -------------------------------------------------------------------------------- /Exam-12.07.2017-Avatar/Avatar/Models/Benders/EarthBender.cs: -------------------------------------------------------------------------------- 1 | public class EarthBender : Bender 2 | { 3 | private double groundSaturation; 4 | 5 | public EarthBender(string name, int power, double groundSaturation) 6 | : base(name, power) 7 | { 8 | this.GroundSaturation = groundSaturation; 9 | } 10 | 11 | public double GroundSaturation 12 | { 13 | get { return this.groundSaturation; } 14 | set { this.groundSaturation = value; } 15 | } 16 | 17 | public override double GetBenderPower() 18 | { 19 | return base.Power * this.GroundSaturation; 20 | } 21 | 22 | public override string ToString() 23 | { 24 | return $"Earth Bender: {this.Name}, Power: {this.Power}, Ground Saturation: {this.GroundSaturation:F2}"; 25 | } 26 | } -------------------------------------------------------------------------------- /Exam-12.07.2017-Avatar/Avatar/Models/Benders/FireBender.cs: -------------------------------------------------------------------------------- 1 | public class FireBender : Bender 2 | { 3 | private double heatAggression; 4 | 5 | public FireBender(string name, int power, double heatAggression) 6 | : base(name, power) 7 | { 8 | this.HeatAggression = heatAggression; 9 | } 10 | 11 | public double HeatAggression 12 | { 13 | get { return this.heatAggression; } 14 | set { this.heatAggression = value; } 15 | } 16 | 17 | public override double GetBenderPower() 18 | { 19 | return base.Power * this.HeatAggression; 20 | } 21 | 22 | public override string ToString() 23 | { 24 | return $"Fire Bender: {this.Name}, Power: {this.Power}, Heat Aggression: {this.HeatAggression:F2}"; 25 | } 26 | } -------------------------------------------------------------------------------- /Exam-12.07.2017-Avatar/Avatar/Models/Benders/WaterBender.cs: -------------------------------------------------------------------------------- 1 | public class WaterBender : Bender 2 | { 3 | private double waterClarity; 4 | 5 | public WaterBender(string name, int power, double waterClarity) 6 | : base(name, power) 7 | { 8 | this.WaterClarity = waterClarity; 9 | } 10 | 11 | public double WaterClarity 12 | { 13 | get { return this.waterClarity; } 14 | set { this.waterClarity = value; } 15 | } 16 | 17 | public override double GetBenderPower() 18 | { 19 | return base.Power * this.WaterClarity; 20 | } 21 | 22 | public override string ToString() 23 | { 24 | return $"Water Bender: {this.Name}, Power: {this.Power}, Water Clarity: {this.WaterClarity:F2}"; 25 | } 26 | } -------------------------------------------------------------------------------- /Exam-12.07.2017-Avatar/Avatar/Models/Monuments/AirMonument.cs: -------------------------------------------------------------------------------- 1 | public class AirMonument : Monument 2 | { 3 | private int airAffinity; 4 | 5 | public AirMonument(string name, int airAffinity) 6 | : base(name) 7 | { 8 | this.AirAffinity = airAffinity; 9 | } 10 | 11 | public int AirAffinity 12 | { 13 | get { return this.airAffinity; } 14 | set { this.airAffinity = value; } 15 | } 16 | 17 | public override double GetMomumentPower() 18 | { 19 | return this.AirAffinity; 20 | } 21 | 22 | public override string ToString() 23 | { 24 | return $"Air Monument: {this.Name}, Air Affinity: {this.AirAffinity}"; 25 | } 26 | } -------------------------------------------------------------------------------- /Exam-12.07.2017-Avatar/Avatar/Models/Monuments/EarthMonument.cs: -------------------------------------------------------------------------------- 1 | public class EarthMonument : Monument 2 | { 3 | private int earthAffnity; 4 | 5 | public EarthMonument(string name, int earthAffnity) 6 | : base(name) 7 | { 8 | this.EarthAffnity = earthAffnity; 9 | } 10 | 11 | public int EarthAffnity 12 | { 13 | get { return this.earthAffnity; } 14 | set { this.earthAffnity = value; } 15 | } 16 | 17 | public override double GetMomumentPower() 18 | { 19 | return this.EarthAffnity; 20 | } 21 | 22 | public override string ToString() 23 | { 24 | return $"Earth Monument: {this.Name}, Earth Affinity: {this.EarthAffnity}"; 25 | } 26 | } -------------------------------------------------------------------------------- /Exam-12.07.2017-Avatar/Avatar/Models/Monuments/FireMonument.cs: -------------------------------------------------------------------------------- 1 | public class FireMonument : Monument 2 | { 3 | private int fireAffinity; 4 | 5 | public FireMonument(string name, int fireAffinity) 6 | : base(name) 7 | { 8 | this.FireAffinity = fireAffinity; 9 | } 10 | 11 | public int FireAffinity 12 | { 13 | get { return this.fireAffinity; } 14 | set { this.fireAffinity = value; } 15 | } 16 | 17 | public override double GetMomumentPower() 18 | { 19 | return this.FireAffinity; 20 | } 21 | 22 | public override string ToString() 23 | { 24 | return $"Fire Monument: {this.Name}, Fire Affinity: {this.FireAffinity}"; 25 | } 26 | } -------------------------------------------------------------------------------- /Exam-12.07.2017-Avatar/Avatar/Models/Monuments/Monument.cs: -------------------------------------------------------------------------------- 1 | public abstract class Monument 2 | { 3 | private string name; 4 | 5 | protected Monument(string name) 6 | { 7 | this.Name = name; 8 | } 9 | 10 | public string Name 11 | { 12 | get { return this.name; } 13 | set { this.name = value; } 14 | } 15 | 16 | public abstract double GetMomumentPower(); 17 | } -------------------------------------------------------------------------------- /Exam-12.07.2017-Avatar/Avatar/Models/Monuments/WaterMonument.cs: -------------------------------------------------------------------------------- 1 | public class WaterMonument : Monument 2 | { 3 | private int waterAffinity; 4 | 5 | public WaterMonument(string name, int waterAffinity) 6 | : base(name) 7 | { 8 | this.WaterAffinity = waterAffinity; 9 | } 10 | 11 | public int WaterAffinity 12 | { 13 | get { return this.waterAffinity; } 14 | set { this.waterAffinity = value; } 15 | } 16 | 17 | public override double GetMomumentPower() 18 | { 19 | return this.WaterAffinity; 20 | } 21 | 22 | public override string ToString() 23 | { 24 | return $"Water Monument: {this.Name}, Water Affinity: {this.WaterAffinity}"; 25 | } 26 | } -------------------------------------------------------------------------------- /Exam-12.07.2017-Avatar/Avatar/Models/Nation.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | 4 | public class Nation 5 | { 6 | private List benders; 7 | private List monuments; 8 | 9 | public Nation() 10 | { 11 | this.Benders = new List(); 12 | this.Monuments = new List(); 13 | } 14 | 15 | public List Monuments 16 | { 17 | get { return this.monuments; } 18 | set { this.monuments = value; } 19 | } 20 | 21 | public List Benders 22 | { 23 | get { return this.benders; } 24 | set { this.benders = value; } 25 | } 26 | 27 | public double TotalPower => this.GetTotalPower(); 28 | 29 | private double GetTotalPower() 30 | { 31 | double bendersPower = this.Benders.Sum(b => b.GetBenderPower()); 32 | double monumentPower = this.Monuments.Sum(m => m.GetMomumentPower()); 33 | double totalPower = bendersPower + ((bendersPower / 100) * monumentPower); 34 | return totalPower; 35 | } 36 | } -------------------------------------------------------------------------------- /Exam-12.07.2017-Avatar/Avatar/Startup.cs: -------------------------------------------------------------------------------- 1 | public class Startup 2 | { 3 | public static void Main() 4 | { 5 | Engine engine = new Engine(); 6 | engine.Run(); 7 | } 8 | } -------------------------------------------------------------------------------- /Exam-16.07.2017-Minedraft/Minedraft-Framework/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Exam-16.07.2017-Minedraft/Minedraft-Framework/Factories/HarvesterFactory.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | public class HarvesterFactory 4 | { 5 | public static Harvester CreateHarvester(List parts) 6 | { 7 | string type = parts[0]; 8 | switch (type) 9 | { 10 | case "Sonic": 11 | return new SonicHarvester(parts[1], double.Parse(parts[2]), double.Parse(parts[3]), int.Parse(parts[4])); 12 | case "Hammer": 13 | return new HammerHarvester(parts[1], double.Parse(parts[2]), double.Parse(parts[3])); 14 | default: 15 | return null; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Exam-16.07.2017-Minedraft/Minedraft-Framework/Factories/ProviderFactory.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | public class ProviderFactory 4 | { 5 | public static Provider CreateProvider(List parts) 6 | { 7 | string type = parts[0]; 8 | switch (type) 9 | { 10 | case "Solar": 11 | return new SolarProvider(parts[1], double.Parse(parts[2])); 12 | case "Pressure": 13 | return new PressureProvider(parts[1], double.Parse(parts[2])); 14 | default: 15 | return null; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Exam-16.07.2017-Minedraft/Minedraft-Framework/Models/Harvesters/HammerHarvester.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | 3 | public class HammerHarvester : Harvester 4 | { 5 | private const double IncreaseOreOutput = 200; 6 | private const double IncreaseEnergyRequirement = 100; 7 | 8 | public HammerHarvester(string id, double oreOutput, double energyRequirement) 9 | : base(id, oreOutput, energyRequirement) 10 | { 11 | this.OreOutput += this.OreOutput * (200 / 100.0); 12 | this.EnergyRequirement += this.EnergyRequirement * (100 / 100.0); 13 | } 14 | 15 | public override string ToString() 16 | { 17 | StringBuilder sb = new StringBuilder(); 18 | sb.AppendLine($"Hammer Harvester - {this.Id}") 19 | .Append(base.ToString()); 20 | return sb.ToString(); 21 | } 22 | } -------------------------------------------------------------------------------- /Exam-16.07.2017-Minedraft/Minedraft-Framework/Models/Harvesters/SonicHarvester.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | 4 | public class SonicHarvester : Harvester 5 | { 6 | private int sonicFactor; 7 | 8 | public SonicHarvester(string id, double oreOutput, double energyRequirement, int sonicFactor) 9 | : base(id, oreOutput, energyRequirement) 10 | { 11 | this.SonicFactor = sonicFactor; 12 | this.EnergyRequirement /= this.SonicFactor; 13 | } 14 | 15 | public int SonicFactor 16 | { 17 | get { return this.sonicFactor; } 18 | set 19 | { 20 | if (value < 1 || value > 10) 21 | { 22 | throw new ArgumentException($"Harvester is not registered, because of it's {nameof(this.SonicFactor)}"); 23 | } 24 | this.sonicFactor = value; 25 | } 26 | } 27 | 28 | public override string ToString() 29 | { 30 | StringBuilder sb = new StringBuilder(); 31 | sb.AppendLine($"Sonic Harvester - {this.Id}") 32 | .Append(base.ToString()); 33 | return sb.ToString(); 34 | } 35 | } -------------------------------------------------------------------------------- /Exam-16.07.2017-Minedraft/Minedraft-Framework/Models/Machine.cs: -------------------------------------------------------------------------------- 1 | public abstract class Machine 2 | { 3 | private string id; 4 | 5 | protected Machine(string id) 6 | { 7 | this.Id = id; 8 | } 9 | 10 | public string Id 11 | { 12 | get { return this.id; } 13 | protected set { this.id = value; } 14 | } 15 | } -------------------------------------------------------------------------------- /Exam-16.07.2017-Minedraft/Minedraft-Framework/Models/Providers/PressureProvider.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | 3 | public class PressureProvider : Provider 4 | { 5 | private const double IncreaseEnergyOutput = 50; 6 | 7 | public PressureProvider(string id, double energyOutput) 8 | : base(id, energyOutput) 9 | { 10 | this.EnergyOutput += this.EnergyOutput * (50 / 100.0); 11 | } 12 | 13 | public override string ToString() 14 | { 15 | StringBuilder sb = new StringBuilder(); 16 | sb.AppendLine($"Pressure Provider - {this.Id}") 17 | .Append(base.ToString()); 18 | return sb.ToString(); 19 | } 20 | } -------------------------------------------------------------------------------- /Exam-16.07.2017-Minedraft/Minedraft-Framework/Models/Providers/Provider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public abstract class Provider : Machine 4 | { 5 | private double energyOutput; 6 | 7 | protected Provider(string id, double energyOutput) 8 | : base(id) 9 | { 10 | this.EnergyOutput = energyOutput; 11 | } 12 | 13 | public double EnergyOutput 14 | { 15 | get { return this.energyOutput; } 16 | protected set 17 | { 18 | if (value < 0 || value > 10000) 19 | { 20 | throw new ArgumentException($"Provider is not registered, because of it's {nameof(this.EnergyOutput)}"); 21 | } 22 | this.energyOutput = value; 23 | } 24 | } 25 | 26 | public override string ToString() 27 | { 28 | return $"Energy Output: {this.EnergyOutput}"; 29 | } 30 | } -------------------------------------------------------------------------------- /Exam-16.07.2017-Minedraft/Minedraft-Framework/Models/Providers/SolarProvider.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | 3 | public class SolarProvider : Provider 4 | { 5 | public SolarProvider(string id, double energyOutput) 6 | : base(id, energyOutput) 7 | { 8 | } 9 | 10 | public override string ToString() 11 | { 12 | StringBuilder sb = new StringBuilder(); 13 | sb.AppendLine($"Solar Provider - {this.Id}") 14 | .Append(base.ToString()); 15 | return sb.ToString(); 16 | } 17 | } -------------------------------------------------------------------------------- /Exam-16.07.2017-Minedraft/Minedraft-Framework/Startup.cs: -------------------------------------------------------------------------------- 1 | public class Startup 2 | { 3 | public static void Main() 4 | { 5 | Engine engine = new Engine(); 6 | engine.Run(); 7 | } 8 | } -------------------------------------------------------------------------------- /Exam-16.07.2017-Minedraft/Minedraft/Factories/HarvesterFactory.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | public class HarvesterFactory 4 | { 5 | public static Harvester CreateHarvester(List arguments) 6 | { 7 | string type = arguments[0]; 8 | switch (type) 9 | { 10 | case "Hammer": 11 | return new HammerHarvester(arguments[1], double.Parse(arguments[2]), double.Parse(arguments[3])); 12 | case "Sonic": 13 | return new SonicHarvester(arguments[1], double.Parse(arguments[2]), double.Parse(arguments[3]), int.Parse(arguments[4])); 14 | } 15 | return null; 16 | } 17 | } -------------------------------------------------------------------------------- /Exam-16.07.2017-Minedraft/Minedraft/Factories/ProviderFactory.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | public class ProviderFactory 4 | { 5 | public static Provider CreateProvider(List arguments) 6 | { 7 | string type = arguments[0]; 8 | switch (type) 9 | { 10 | case "Pressure": 11 | return new PressureProvider(arguments[1], double.Parse(arguments[2])); 12 | case "Solar": 13 | return new SolarProvider(arguments[1], double.Parse(arguments[2])); 14 | } 15 | return null; 16 | } 17 | } -------------------------------------------------------------------------------- /Exam-16.07.2017-Minedraft/Minedraft/Minedraft.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Exam-16.07.2017-Minedraft/Minedraft/Models/Harvesters/HammerHarvester.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | 3 | public class HammerHarvester : Harvester 4 | { 5 | private const int IncreaseOreIoutput = 200; 6 | private const int IncreaseEnergyRequirment = 100; 7 | 8 | public HammerHarvester(string id, double oreOutput, double energyRequirement) 9 | : base(id, oreOutput, energyRequirement) 10 | { 11 | this.OreOutput = oreOutput + (oreOutput * IncreaseOreIoutput / 100); 12 | this.EnergyRequirement = energyRequirement + (energyRequirement * IncreaseEnergyRequirment / 100); 13 | } 14 | 15 | public override string ToString() 16 | { 17 | StringBuilder sb = new StringBuilder(); 18 | sb.AppendLine($"Hammer Harvester - {this.Id}"); 19 | sb.Append(base.ToString()); 20 | return sb.ToString(); 21 | } 22 | } -------------------------------------------------------------------------------- /Exam-16.07.2017-Minedraft/Minedraft/Models/Harvesters/SonicHarvester.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | 3 | public class SonicHarvester : Harvester 4 | { 5 | private int sonicFactor; 6 | 7 | public SonicHarvester(string id, double oreOutput, double energyRequirement, int sonicFactor) 8 | : base(id, oreOutput, energyRequirement) 9 | { 10 | this.SonicFactor = sonicFactor; 11 | this.EnergyRequirement /= this.SonicFactor; 12 | } 13 | 14 | public int SonicFactor 15 | { 16 | get { return this.sonicFactor; } 17 | set { this.sonicFactor = value; } 18 | } 19 | 20 | public override string ToString() 21 | { 22 | StringBuilder sb = new StringBuilder(); 23 | sb.AppendLine($"Sonic Harvester - {this.Id}"); 24 | sb.Append(base.ToString()); 25 | return sb.ToString(); 26 | } 27 | } -------------------------------------------------------------------------------- /Exam-16.07.2017-Minedraft/Minedraft/Models/Machine.cs: -------------------------------------------------------------------------------- 1 | public abstract class Machine 2 | { 3 | private string id; 4 | 5 | protected Machine(string id) 6 | { 7 | this.Id = id; 8 | } 9 | 10 | public string Id 11 | { 12 | get { return this.id; } 13 | protected set { this.id = value; } 14 | } 15 | } -------------------------------------------------------------------------------- /Exam-16.07.2017-Minedraft/Minedraft/Models/Providers/PressureProvider.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | 3 | public class PressureProvider : Provider 4 | { 5 | private const int IncreaseEnergyOutput = 50; 6 | 7 | public PressureProvider(string id, double energyOutput) 8 | : base(id, energyOutput) 9 | { 10 | this.EnergyOutput = energyOutput + (energyOutput * IncreaseEnergyOutput / 100.0); 11 | } 12 | 13 | public override string ToString() 14 | { 15 | StringBuilder sb = new StringBuilder(); 16 | sb.AppendLine($"Pressure Provider - {this.Id}"); 17 | sb.Append(base.ToString()); 18 | return sb.ToString(); 19 | } 20 | } -------------------------------------------------------------------------------- /Exam-16.07.2017-Minedraft/Minedraft/Models/Providers/Provider.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | 3 | public abstract class Provider : Machine 4 | { 5 | private double energyOutput; 6 | 7 | protected Provider(string id, double energyOutput) 8 | :base(id) 9 | { 10 | this.EnergyOutput = energyOutput; 11 | } 12 | 13 | public double EnergyOutput 14 | { 15 | get { return this.energyOutput; } 16 | protected set 17 | { 18 | Validator.CheckProviderEnergyRequirment(nameof(this.EnergyOutput), value); 19 | this.energyOutput = value; 20 | } 21 | } 22 | 23 | public override string ToString() 24 | { 25 | StringBuilder sb = new StringBuilder(); 26 | sb.Append($"Energy Output: {this.EnergyOutput}"); 27 | return sb.ToString(); 28 | } 29 | } -------------------------------------------------------------------------------- /Exam-16.07.2017-Minedraft/Minedraft/Models/Providers/SolarProvider.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | 3 | public class SolarProvider : Provider 4 | { 5 | public SolarProvider(string id, double energyOutput) 6 | : base(id, energyOutput) 7 | { 8 | } 9 | 10 | public override string ToString() 11 | { 12 | StringBuilder sb = new StringBuilder(); 13 | sb.AppendLine($"Solar Provider - {this.Id}"); 14 | sb.Append(base.ToString()); 15 | return sb.ToString(); 16 | } 17 | } -------------------------------------------------------------------------------- /Exam-16.07.2017-Minedraft/Minedraft/Startup.cs: -------------------------------------------------------------------------------- 1 | public class Startup 2 | { 3 | public static void Main() 4 | { 5 | Engine engine = new Engine(); 6 | engine.Run(); 7 | } 8 | } -------------------------------------------------------------------------------- /Exam-16.07.2017-Minedraft/Minedraft/Validations/Validator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public class Validator 4 | { 5 | public static void CheckHarvesterOreOutput(string property, double value) 6 | { 7 | if (value < 0) 8 | { 9 | throw new ArgumentException($"Harvester is not registered, because of it's {property}"); 10 | } 11 | } 12 | 13 | public static void CheckHarvesterEnergyRequirement(string property, double value) 14 | { 15 | if (value < 0 || value > 20000) 16 | { 17 | throw new ArgumentException($"Harvester is not registered, because of it's {property}"); 18 | } 19 | } 20 | 21 | public static void CheckProviderEnergyRequirment(string property, double value) 22 | { 23 | if (value < 0 || value > 10000) 24 | { 25 | throw new ArgumentException($"Provider is not registered, because of it's {property}"); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Exam-18.03.2018-DungeonsAndCodeWizards/DungeonsAndCodeWizards/DungeonsAndCodeWizards.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Exam-18.03.2018-DungeonsAndCodeWizards/DungeonsAndCodeWizards/Factories/CharacterFactory.cs: -------------------------------------------------------------------------------- 1 | namespace DungeonsAndCodeWizards.Factories 2 | { 3 | using System; 4 | using Models.Characters; 5 | using Models.Enums; 6 | 7 | public class CharacterFactory 8 | { 9 | public Character CreateCharacter(string faction, string type, string name) 10 | { 11 | Faction currentFaction; 12 | if (!Enum.TryParse(faction, out currentFaction)) 13 | { 14 | throw new ArgumentException($"Invalid faction \"{faction}\"!"); 15 | } 16 | 17 | switch (type) 18 | { 19 | case "Warrior": 20 | return new Warrior(name, currentFaction); 21 | case "Cleric": 22 | return new Cleric(name, currentFaction); 23 | default: 24 | throw new ArgumentException($"Invalid character type \"{type}\"!"); 25 | } 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Exam-18.03.2018-DungeonsAndCodeWizards/DungeonsAndCodeWizards/Factories/ItemFactory.cs: -------------------------------------------------------------------------------- 1 | namespace DungeonsAndCodeWizards.Factories 2 | { 3 | using System; 4 | using Models.Items; 5 | 6 | public class ItemFactory 7 | { 8 | public Item CreateItem(string name) 9 | { 10 | switch (name) 11 | { 12 | case "ArmorRepairKit": 13 | return new ArmorRepairKit(); 14 | case "HealthPotion": 15 | return new HealthPotion(); 16 | case "PoisonPotion": 17 | return new PoisonPotion(); 18 | default: 19 | throw new ArgumentException($"Invalid item \"{name}\"!"); 20 | } 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Exam-18.03.2018-DungeonsAndCodeWizards/DungeonsAndCodeWizards/Models/Bags/Backpack.cs: -------------------------------------------------------------------------------- 1 | namespace DungeonsAndCodeWizards.Models.Bags 2 | { 3 | public class Backpack : Bag 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /Exam-18.03.2018-DungeonsAndCodeWizards/DungeonsAndCodeWizards/Models/Bags/Satchel.cs: -------------------------------------------------------------------------------- 1 | namespace DungeonsAndCodeWizards.Models.Bags 2 | { 3 | public class Satchel : Bag 4 | { 5 | private const int SatchelCapacity = 20; 6 | 7 | public Satchel() 8 | : base(SatchelCapacity) 9 | { 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Exam-18.03.2018-DungeonsAndCodeWizards/DungeonsAndCodeWizards/Models/Enums/Faction.cs: -------------------------------------------------------------------------------- 1 | namespace DungeonsAndCodeWizards.Models.Enums 2 | { 3 | public enum Faction 4 | { 5 | CSharp, 6 | Java 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Exam-18.03.2018-DungeonsAndCodeWizards/DungeonsAndCodeWizards/Models/Interfaces/IAttackable.cs: -------------------------------------------------------------------------------- 1 | namespace DungeonsAndCodeWizards.Models.Interfaces 2 | { 3 | using Characters; 4 | 5 | public interface IAttackable 6 | { 7 | void Attack(Character character); 8 | } 9 | } -------------------------------------------------------------------------------- /Exam-18.03.2018-DungeonsAndCodeWizards/DungeonsAndCodeWizards/Models/Interfaces/IHealable.cs: -------------------------------------------------------------------------------- 1 | namespace DungeonsAndCodeWizards.Models.Interfaces 2 | { 3 | using Characters; 4 | 5 | public interface IHealable 6 | { 7 | void Heal(Character character); 8 | } 9 | } -------------------------------------------------------------------------------- /Exam-18.03.2018-DungeonsAndCodeWizards/DungeonsAndCodeWizards/Models/Items/ArmorRepairKit.cs: -------------------------------------------------------------------------------- 1 | namespace DungeonsAndCodeWizards.Models.Items 2 | { 3 | using Characters; 4 | 5 | public class ArmorRepairKit : Item 6 | { 7 | private const int ArmorRepairKitWeight = 10; 8 | 9 | public ArmorRepairKit() 10 | : base(ArmorRepairKitWeight) 11 | { 12 | } 13 | 14 | public override void AffectCharacter(Character character) 15 | { 16 | base.AffectCharacter(character); 17 | character.Armor = character.BaseArmor; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Exam-18.03.2018-DungeonsAndCodeWizards/DungeonsAndCodeWizards/Models/Items/HealthPotion.cs: -------------------------------------------------------------------------------- 1 | namespace DungeonsAndCodeWizards.Models.Items 2 | { 3 | using Characters; 4 | 5 | public class HealthPotion : Item 6 | { 7 | private const int HealthPotionWeight = 5; 8 | private const double CharacterHealthIncrease = 20; 9 | 10 | public HealthPotion() 11 | : base(HealthPotionWeight) 12 | { 13 | } 14 | 15 | public override void AffectCharacter(Character character) 16 | { 17 | base.AffectCharacter(character); 18 | character.Health += CharacterHealthIncrease; 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /Exam-18.03.2018-DungeonsAndCodeWizards/DungeonsAndCodeWizards/Models/Items/Item.cs: -------------------------------------------------------------------------------- 1 | namespace DungeonsAndCodeWizards.Models.Items 2 | { 3 | using System; 4 | using Characters; 5 | 6 | public abstract class Item 7 | { 8 | protected Item(int weight) 9 | { 10 | this.Weight = weight; 11 | } 12 | 13 | public int Weight { get; } 14 | 15 | public virtual void AffectCharacter(Character character) 16 | { 17 | if (!character.IsAlive) 18 | { 19 | throw new InvalidOperationException("Must be alive to perform this action!"); 20 | } 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Exam-18.03.2018-DungeonsAndCodeWizards/DungeonsAndCodeWizards/Models/Items/PoisonPotion.cs: -------------------------------------------------------------------------------- 1 | namespace DungeonsAndCodeWizards.Models.Items 2 | { 3 | using System; 4 | using Characters; 5 | 6 | public class PoisonPotion : Item 7 | { 8 | private const int PoisonPotionWeight = 5; 9 | private const double CharacterHealthDecrease = 20; 10 | 11 | public PoisonPotion() 12 | : base(PoisonPotionWeight) 13 | { 14 | } 15 | 16 | public override void AffectCharacter(Character character) 17 | { 18 | base.AffectCharacter(character); 19 | character.Health -= CharacterHealthDecrease; 20 | character.Health = Math.Max(0, character.Health); 21 | 22 | if (character.Health == 0) 23 | { 24 | character.IsAlive = false; 25 | } 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Exam-18.03.2018-DungeonsAndCodeWizards/DungeonsAndCodeWizards/StartUp.cs: -------------------------------------------------------------------------------- 1 | namespace DungeonsAndCodeWizards 2 | { 3 | using Controllers; 4 | 5 | public class StartUp 6 | { 7 | public static void Main() 8 | { 9 | Engine engine = new Engine(); 10 | engine.Run(); 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /Exam-26.04.2018-StorageMaster/StorageMaster/Factories/ProductFactory.cs: -------------------------------------------------------------------------------- 1 | namespace StorageMaster.Factories 2 | { 3 | using System; 4 | using Models.Products; 5 | using OutputMessages; 6 | 7 | public class ProductFactory 8 | { 9 | public Product CreateProduct(string type, double price) 10 | { 11 | switch (type) 12 | { 13 | case "Gpu": 14 | return new Gpu(price); 15 | case "HardDrive": 16 | return new HardDrive(price); 17 | case "Ram": 18 | return new Ram(price); 19 | case "SolidStateDrive": 20 | return new SolidStateDrive(price); 21 | default: 22 | throw new InvalidOperationException(OutputMessage.InvalidProduct); 23 | } 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /Exam-26.04.2018-StorageMaster/StorageMaster/Factories/StorageFactory.cs: -------------------------------------------------------------------------------- 1 | namespace StorageMaster.Factories 2 | { 3 | using System; 4 | using Models.Storages; 5 | using OutputMessages; 6 | 7 | public class StorageFactory 8 | { 9 | public Storage CreateStorage(string type, string name) 10 | { 11 | switch (type) 12 | { 13 | case "AutomatedWarehouse": 14 | return new AutomatedWarehouse(name); 15 | case "DistributionCenter": 16 | return new DistributionCenter(name); 17 | case "Warehouse": 18 | return new Warehouse(name); 19 | default: 20 | throw new InvalidOperationException(OutputMessage.InvalidStorage); 21 | } 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /Exam-26.04.2018-StorageMaster/StorageMaster/Factories/VehicleFactory.cs: -------------------------------------------------------------------------------- 1 | namespace StorageMaster.Factories 2 | { 3 | using System; 4 | using Models.Vehicles; 5 | using OutputMessages; 6 | 7 | public class VehicleFactory 8 | { 9 | public Vehicle CreateVehicle(string type) 10 | { 11 | switch (type) 12 | { 13 | case "Semi": 14 | return new Semi(); 15 | case "Truck": 16 | return new Truck(); 17 | case "Van": 18 | return new Van(); 19 | default: 20 | throw new InvalidOperationException(OutputMessage.InvalidVehicle); 21 | } 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /Exam-26.04.2018-StorageMaster/StorageMaster/Models/Products/Gpu.cs: -------------------------------------------------------------------------------- 1 | namespace StorageMaster.Models.Products 2 | { 3 | public class Gpu : Product 4 | { 5 | private const double DefaultWeight = 0.7; 6 | 7 | public Gpu(double price) 8 | : base(price, DefaultWeight) 9 | { 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /Exam-26.04.2018-StorageMaster/StorageMaster/Models/Products/HardDrive.cs: -------------------------------------------------------------------------------- 1 | namespace StorageMaster.Models.Products 2 | { 3 | public class HardDrive : Product 4 | { 5 | private const double DefaultWeight = 1; 6 | 7 | public HardDrive(double price) 8 | : base(price, DefaultWeight) 9 | { 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /Exam-26.04.2018-StorageMaster/StorageMaster/Models/Products/Product.cs: -------------------------------------------------------------------------------- 1 | namespace StorageMaster.Models.Products 2 | { 3 | using System; 4 | using OutputMessages; 5 | 6 | public abstract class Product 7 | { 8 | private double price; 9 | 10 | protected Product(double price, double weight) 11 | { 12 | this.Price = price; 13 | this.Weight = weight; 14 | } 15 | 16 | public double Price 17 | { 18 | get { return this.price; } 19 | private set 20 | { 21 | if (value < 0) 22 | { 23 | throw new InvalidOperationException(OutputMessage.NegativePrice); 24 | } 25 | this.price = value; 26 | } 27 | } 28 | 29 | public double Weight { get; } 30 | } 31 | } -------------------------------------------------------------------------------- /Exam-26.04.2018-StorageMaster/StorageMaster/Models/Products/Ram.cs: -------------------------------------------------------------------------------- 1 | namespace StorageMaster.Models.Products 2 | { 3 | public class Ram : Product 4 | { 5 | private const double DefaultWeight = 0.1; 6 | 7 | public Ram(double price) 8 | : base(price, DefaultWeight) 9 | { 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /Exam-26.04.2018-StorageMaster/StorageMaster/Models/Products/SolidStateDrive.cs: -------------------------------------------------------------------------------- 1 | namespace StorageMaster.Models.Products 2 | { 3 | public class SolidStateDrive : Product 4 | { 5 | private const double DefaultWeight = 0.2; 6 | 7 | public SolidStateDrive(double price) 8 | : base(price, DefaultWeight) 9 | { 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /Exam-26.04.2018-StorageMaster/StorageMaster/Models/Storages/AutomatedWarehouse.cs: -------------------------------------------------------------------------------- 1 | namespace StorageMaster.Models.Storages 2 | { 3 | using System.Collections.Generic; 4 | using Vehicles; 5 | 6 | public class AutomatedWarehouse : Storage 7 | { 8 | private const int DefaultCapacity = 1; 9 | private const int DefaultGarageSlots = 2; 10 | 11 | public AutomatedWarehouse(string name) 12 | : base(name, DefaultCapacity, DefaultGarageSlots, new List(){new Truck()}) 13 | { 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /Exam-26.04.2018-StorageMaster/StorageMaster/Models/Storages/DistributionCenter.cs: -------------------------------------------------------------------------------- 1 | namespace StorageMaster.Models.Storages 2 | { 3 | using System.Collections.Generic; 4 | using Vehicles; 5 | 6 | public class DistributionCenter : Storage 7 | { 8 | private const int DefaultCapacity = 2; 9 | private const int DefaultGarageSlots = 5; 10 | 11 | public DistributionCenter(string name) 12 | : base(name, DefaultCapacity, DefaultGarageSlots, new List(){new Van(), new Van(), new Van()}) 13 | { 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /Exam-26.04.2018-StorageMaster/StorageMaster/Models/Storages/Warehouse.cs: -------------------------------------------------------------------------------- 1 | namespace StorageMaster.Models.Storages 2 | { 3 | using System.Collections.Generic; 4 | using Vehicles; 5 | 6 | public class Warehouse : Storage 7 | { 8 | private const int DefaultCapacity = 10; 9 | private const int DefaultGarageSlots = 10; 10 | 11 | public Warehouse(string name) 12 | : base(name, DefaultCapacity, DefaultGarageSlots, new List(){new Semi(), new Semi(), new Semi()}) 13 | { 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /Exam-26.04.2018-StorageMaster/StorageMaster/Models/Vehicles/Semi.cs: -------------------------------------------------------------------------------- 1 | namespace StorageMaster.Models.Vehicles 2 | { 3 | public class Semi : Vehicle 4 | { 5 | private const int DefaultCapacity = 10; 6 | 7 | public Semi() 8 | : base(DefaultCapacity) 9 | { 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /Exam-26.04.2018-StorageMaster/StorageMaster/Models/Vehicles/Truck.cs: -------------------------------------------------------------------------------- 1 | namespace StorageMaster.Models.Vehicles 2 | { 3 | public class Truck : Vehicle 4 | { 5 | private const int DefaultCapacity = 5; 6 | 7 | public Truck() 8 | : base(DefaultCapacity) 9 | { 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /Exam-26.04.2018-StorageMaster/StorageMaster/Models/Vehicles/Van.cs: -------------------------------------------------------------------------------- 1 | namespace StorageMaster.Models.Vehicles 2 | { 3 | public class Van : Vehicle 4 | { 5 | private const int DefaultCapacity = 2; 6 | 7 | public Van() 8 | : base(DefaultCapacity) 9 | { 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /Exam-26.04.2018-StorageMaster/StorageMaster/StartUp.cs: -------------------------------------------------------------------------------- 1 | namespace StorageMaster 2 | { 3 | using Core; 4 | 5 | public class StartUp 6 | { 7 | public static void Main() 8 | { 9 | Engine engine = new Engine(); 10 | engine.Run(); 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /Exam-26.04.2018-StorageMaster/StorageMaster/StorageMaster.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Resources/01. Defining-Classes-Lab.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dobroslav-atanasov/CSharp-OOP-Basics/068472407aa87e14bbd25e0c27838c55db710de5/Resources/01. Defining-Classes-Lab.docx -------------------------------------------------------------------------------- /Resources/02. Defining-Classes-Exercises.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dobroslav-atanasov/CSharp-OOP-Basics/068472407aa87e14bbd25e0c27838c55db710de5/Resources/02. Defining-Classes-Exercises.docx -------------------------------------------------------------------------------- /Resources/03. Working-with-Abstraction-Lab.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dobroslav-atanasov/CSharp-OOP-Basics/068472407aa87e14bbd25e0c27838c55db710de5/Resources/03. Working-with-Abstraction-Lab.docx -------------------------------------------------------------------------------- /Resources/04. Working-with-Abstraction-Exercises.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dobroslav-atanasov/CSharp-OOP-Basics/068472407aa87e14bbd25e0c27838c55db710de5/Resources/04. Working-with-Abstraction-Exercises.docx -------------------------------------------------------------------------------- /Resources/05. Encapsulation-Lab.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dobroslav-atanasov/CSharp-OOP-Basics/068472407aa87e14bbd25e0c27838c55db710de5/Resources/05. Encapsulation-Lab.docx -------------------------------------------------------------------------------- /Resources/06. Encapsulation-Exercises.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dobroslav-atanasov/CSharp-OOP-Basics/068472407aa87e14bbd25e0c27838c55db710de5/Resources/06. Encapsulation-Exercises.docx -------------------------------------------------------------------------------- /Resources/07. Inheritance-Lab.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dobroslav-atanasov/CSharp-OOP-Basics/068472407aa87e14bbd25e0c27838c55db710de5/Resources/07. Inheritance-Lab.docx -------------------------------------------------------------------------------- /Resources/08. Inheritance-Exercises.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dobroslav-atanasov/CSharp-OOP-Basics/068472407aa87e14bbd25e0c27838c55db710de5/Resources/08. Inheritance-Exercises.docx -------------------------------------------------------------------------------- /Resources/09. Interfaces-and-Abstraction-Lab.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dobroslav-atanasov/CSharp-OOP-Basics/068472407aa87e14bbd25e0c27838c55db710de5/Resources/09. Interfaces-and-Abstraction-Lab.docx -------------------------------------------------------------------------------- /Resources/10. Interfaces-and-Abstraction-Exercises.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dobroslav-atanasov/CSharp-OOP-Basics/068472407aa87e14bbd25e0c27838c55db710de5/Resources/10. Interfaces-and-Abstraction-Exercises.docx -------------------------------------------------------------------------------- /Resources/11. Polymorphism-Lab.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dobroslav-atanasov/CSharp-OOP-Basics/068472407aa87e14bbd25e0c27838c55db710de5/Resources/11. Polymorphism-Lab.docx -------------------------------------------------------------------------------- /Resources/12. Polymorphism-Exercises.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dobroslav-atanasov/CSharp-OOP-Basics/068472407aa87e14bbd25e0c27838c55db710de5/Resources/12. Polymorphism-Exercises.docx -------------------------------------------------------------------------------- /Resources/Exam-05.09.2017-Grand-Prix/Grand-Prix.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dobroslav-atanasov/CSharp-OOP-Basics/068472407aa87e14bbd25e0c27838c55db710de5/Resources/Exam-05.09.2017-Grand-Prix/Grand-Prix.docx -------------------------------------------------------------------------------- /Resources/Exam-11.07.2017-Need-For-Speed/Need-For-Speed.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dobroslav-atanasov/CSharp-OOP-Basics/068472407aa87e14bbd25e0c27838c55db710de5/Resources/Exam-11.07.2017-Need-For-Speed/Need-For-Speed.docx -------------------------------------------------------------------------------- /Resources/Exam-12.07.2017-Avatar/Avatar.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dobroslav-atanasov/CSharp-OOP-Basics/068472407aa87e14bbd25e0c27838c55db710de5/Resources/Exam-12.07.2017-Avatar/Avatar.docx -------------------------------------------------------------------------------- /Resources/Exam-16.07.2017-Minedraft/Minedraft.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dobroslav-atanasov/CSharp-OOP-Basics/068472407aa87e14bbd25e0c27838c55db710de5/Resources/Exam-16.07.2017-Minedraft/Minedraft.docx -------------------------------------------------------------------------------- /Resources/Exam-18.03.2018-Dungeons-and-Code-Wizards/DungeonsAndCodeWizards.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dobroslav-atanasov/CSharp-OOP-Basics/068472407aa87e14bbd25e0c27838c55db710de5/Resources/Exam-18.03.2018-Dungeons-and-Code-Wizards/DungeonsAndCodeWizards.docx -------------------------------------------------------------------------------- /Resources/Exam-26.04.2018-Storage-Master/Storage-Master.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dobroslav-atanasov/CSharp-OOP-Basics/068472407aa87e14bbd25e0c27838c55db710de5/Resources/Exam-26.04.2018-Storage-Master/Storage-Master.docx -------------------------------------------------------------------------------- /Resources/Workshop/Workshop-Forum-Part-1.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dobroslav-atanasov/CSharp-OOP-Basics/068472407aa87e14bbd25e0c27838c55db710de5/Resources/Workshop/Workshop-Forum-Part-1.docx -------------------------------------------------------------------------------- /Resources/Workshop/Workshop-Forum-Part-2.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dobroslav-atanasov/CSharp-OOP-Basics/068472407aa87e14bbd25e0c27838c55db710de5/Resources/Workshop/Workshop-Forum-Part-2.docx -------------------------------------------------------------------------------- /Resources/Workshop/Workshop-Forum-Part-3.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dobroslav-atanasov/CSharp-OOP-Basics/068472407aa87e14bbd25e0c27838c55db710de5/Resources/Workshop/Workshop-Forum-Part-3.docx -------------------------------------------------------------------------------- /Workshop-Forum/Forum.App/Controllers/Contracts/IController.cs: -------------------------------------------------------------------------------- 1 | namespace Forum.App.Controllers.Contracts 2 | { 3 | using Enums; 4 | using Forum.App.UserInterface.Contracts; 5 | 6 | public interface IController 7 | { 8 | MenuState ExecuteCommand(int index); 9 | 10 | IView GetView(string userName); 11 | } 12 | } -------------------------------------------------------------------------------- /Workshop-Forum/Forum.App/Controllers/Contracts/IPaginationController.cs: -------------------------------------------------------------------------------- 1 | namespace Forum.App.Controllers.Contracts 2 | { 3 | interface IPaginationController 4 | { 5 | int CurrentPage { get; set; } 6 | } 7 | } -------------------------------------------------------------------------------- /Workshop-Forum/Forum.App/Controllers/Contracts/IReadUserInfoController.cs: -------------------------------------------------------------------------------- 1 | namespace Forum.App.Controllers.Contracts 2 | { 3 | public interface IReadUserInfoController 4 | { 5 | void ReadUsername(); 6 | 7 | void ReadPassword(); 8 | 9 | string Username { get; } 10 | } 11 | } -------------------------------------------------------------------------------- /Workshop-Forum/Forum.App/Controllers/Contracts/IUserRestrictedController.cs: -------------------------------------------------------------------------------- 1 | namespace Forum.App.Controllers.Contracts 2 | { 3 | public interface IUserRestrictedController 4 | { 5 | bool LoggedInUser { get; } 6 | 7 | void UserLogIn(); 8 | 9 | void UserLogOut(); 10 | } 11 | } -------------------------------------------------------------------------------- /Workshop-Forum/Forum.App/Enums/MenuState.cs: -------------------------------------------------------------------------------- 1 | namespace Forum.App.Enums 2 | { 3 | public enum MenuState 4 | { 5 | Main, 6 | Login, 7 | Categories, 8 | OpenCategory, 9 | Signup, 10 | ViewPost, 11 | AddPost, 12 | AddReply, 13 | AddReplyToPost, 14 | Back, 15 | SuccessfulLogIn, 16 | Error, 17 | Rerender, 18 | SignedUp, 19 | SignUpError, 20 | LoggedOut, 21 | PostAdded, 22 | ReplyAdded, 23 | } 24 | } -------------------------------------------------------------------------------- /Workshop-Forum/Forum.App/Enums/SignUpStatus.cs: -------------------------------------------------------------------------------- 1 | namespace Forum.App.Enums 2 | { 3 | public enum SignUpStatus 4 | { 5 | Success, 6 | DetailsError, 7 | UsernameTakenError, 8 | } 9 | } -------------------------------------------------------------------------------- /Workshop-Forum/Forum.App/Exceptions/InvalidCommandException.cs: -------------------------------------------------------------------------------- 1 | namespace Forum.App.Exceptions 2 | { 3 | using System; 4 | 5 | public class InvalidCommandException : Exception 6 | { 7 | public override string Message => "Invalid command!"; 8 | } 9 | } -------------------------------------------------------------------------------- /Workshop-Forum/Forum.App/Forum.App.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Workshop-Forum/Forum.App/StartUp.cs: -------------------------------------------------------------------------------- 1 | namespace Forum.App 2 | { 3 | using Core; 4 | 5 | public class StartUp 6 | { 7 | public static void Main(string[] args) 8 | { 9 | Engine engine = new Engine(); 10 | engine.Run(); 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /Workshop-Forum/Forum.App/UserInterface/Contracts/IInput.cs: -------------------------------------------------------------------------------- 1 | namespace Forum.App.UserInterface.Contracts 2 | { 3 | public interface IInput 4 | { 5 | bool AddCharacter(char character); 6 | 7 | void Delete(); 8 | } 9 | } -------------------------------------------------------------------------------- /Workshop-Forum/Forum.App/UserInterface/Contracts/ILabel.cs: -------------------------------------------------------------------------------- 1 | namespace Forum.App.UserInterface.Contracts 2 | { 3 | using Forum.App; 4 | 5 | public interface ILabel : IPositionable 6 | { 7 | string Text { get; } 8 | 9 | bool IsHidden { get; } 10 | } 11 | } -------------------------------------------------------------------------------- /Workshop-Forum/Forum.App/UserInterface/Contracts/IPositionable.cs: -------------------------------------------------------------------------------- 1 | namespace Forum.App 2 | { 3 | public interface IPositionable 4 | { 5 | Position Position { get; } 6 | } 7 | } -------------------------------------------------------------------------------- /Workshop-Forum/Forum.App/UserInterface/Contracts/IView.cs: -------------------------------------------------------------------------------- 1 | namespace Forum.App.UserInterface.Contracts 2 | { 3 | public interface IView 4 | { 5 | ILabel[] Labels { get; } 6 | 7 | ILabel[] Buttons { get; } 8 | } 9 | } -------------------------------------------------------------------------------- /Workshop-Forum/Forum.App/UserInterface/Label.cs: -------------------------------------------------------------------------------- 1 | namespace Forum.App 2 | { 3 | using Forum.App.UserInterface.Contracts; 4 | 5 | internal class Label : ILabel 6 | { 7 | public Label(string text, Position position, bool isHidden = false) 8 | { 9 | this.Text = text; 10 | this.Position = position; 11 | this.IsHidden = isHidden; 12 | } 13 | 14 | public string Text { get; private set; } 15 | public bool IsHidden { get; private set; } 16 | public Position Position { get; private set; } 17 | } 18 | } -------------------------------------------------------------------------------- /Workshop-Forum/Forum.App/UserInterface/Position.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Forum.App 6 | { 7 | public class Position 8 | { 9 | private int left; 10 | private int top; 11 | 12 | public Position(int left, int top) 13 | { 14 | this.Left = left; 15 | this.Top = top; 16 | } 17 | 18 | public int Top 19 | { 20 | get { return top; } 21 | set { top = value; } 22 | } 23 | 24 | public int Left 25 | { 26 | get { return left; } 27 | set { left = value; } 28 | } 29 | 30 | public static Position ConsoleCenter() 31 | { 32 | int centerTop = Console.WindowHeight / 2; 33 | int centerLeft = Console.WindowWidth / 2; 34 | 35 | Position center = new Position(centerLeft, centerTop); 36 | return center; 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /Workshop-Forum/Forum.Data/Forum.Data.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Library 5 | netcoreapp2.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Workshop-Forum/Forum.Data/ForumData.cs: -------------------------------------------------------------------------------- 1 | namespace Forum.Data 2 | { 3 | using System.Collections.Generic; 4 | using Models; 5 | 6 | public class ForumData 7 | { 8 | public ForumData() 9 | { 10 | this.Categories = DataMapper.LoadCategories(); 11 | this.Users = DataMapper.LoadUsers(); 12 | this.Posts = DataMapper.LoadPosts(); 13 | this.Replies = DataMapper.LoadReplies(); 14 | } 15 | 16 | public List Categories { get; set; } 17 | 18 | public List Users { get; set; } 19 | 20 | public List Posts { get; set; } 21 | 22 | public List Replies { get; set; } 23 | 24 | public void SaveChanges() 25 | { 26 | DataMapper.SaveCategories(this.Categories); 27 | DataMapper.SaveUsers(this.Users); 28 | DataMapper.SavePosts(this.Posts); 29 | DataMapper.SaveReplies(this.Replies); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /Workshop-Forum/Forum.Models/Category.cs: -------------------------------------------------------------------------------- 1 | namespace Forum.Models 2 | { 3 | using System.Collections.Generic; 4 | 5 | public class Category 6 | { 7 | public Category(int id, string name, ICollection postIds) 8 | { 9 | this.Id = id; 10 | this.Name = name; 11 | this.PostIds = new List(postIds); 12 | } 13 | 14 | public int Id { get; set; } 15 | 16 | public string Name { get; set; } 17 | 18 | public ICollection PostIds { get; set; } 19 | } 20 | } -------------------------------------------------------------------------------- /Workshop-Forum/Forum.Models/Forum.Models.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp2.0 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Workshop-Forum/Forum.Models/Post.cs: -------------------------------------------------------------------------------- 1 | namespace Forum.Models 2 | { 3 | using System.Collections.Generic; 4 | 5 | public class Post 6 | { 7 | public Post(int id, string title, string content, int categoryId, int authorId, ICollection replies) 8 | { 9 | this.Id = id; 10 | this.Title = title; 11 | this.Content = content; 12 | this.CategoryId = categoryId; 13 | this.AuthorId = authorId; 14 | this.Replies = new List(replies); 15 | } 16 | 17 | public int Id { get; set; } 18 | 19 | public string Title { get; set; } 20 | 21 | public string Content { get; set; } 22 | 23 | public int CategoryId { get; set; } 24 | 25 | public int AuthorId { get; set; } 26 | 27 | public ICollection Replies { get; set; } 28 | } 29 | } -------------------------------------------------------------------------------- /Workshop-Forum/Forum.Models/Reply.cs: -------------------------------------------------------------------------------- 1 | namespace Forum.Models 2 | { 3 | public class Reply 4 | { 5 | public Reply(int id, string content, int authorId, int postId) 6 | { 7 | this.Id = id; 8 | this.Content = content; 9 | this.AuthorId = authorId; 10 | this.PostId = postId; 11 | } 12 | 13 | public int Id { get; set; } 14 | 15 | public string Content { get; set; } 16 | 17 | public int AuthorId { get; set; } 18 | 19 | public int PostId { get; set; } 20 | } 21 | } -------------------------------------------------------------------------------- /Workshop-Forum/Forum.Models/User.cs: -------------------------------------------------------------------------------- 1 | namespace Forum.Models 2 | { 3 | using System.Collections.Generic; 4 | 5 | public class User 6 | { 7 | public User(int id, string username, string password, ICollection postIds) 8 | { 9 | this.Id = id; 10 | this.Username = username; 11 | this.Password = password; 12 | this.PostIds = new List(postIds); 13 | } 14 | 15 | public int Id { get; set; } 16 | 17 | public string Username { get; set; } 18 | 19 | public string Password { get; set; } 20 | 21 | public ICollection PostIds { get; set; } 22 | } 23 | } --------------------------------------------------------------------------------