{"id":19404283,"url":"https://github.com/dussanfreire/oop-polymorphism__example-in-c-sharp","last_synced_at":"2025-02-25T00:32:13.906Z","repository":{"id":116509586,"uuid":"356756593","full_name":"DussanFreire/OOP-Polymorphism__Example-in-C-sharp","owner":"DussanFreire","description":null,"archived":false,"fork":false,"pushed_at":"2024-10-09T18:48:28.000Z","size":129,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-07T12:47:32.539Z","etag":null,"topics":["cshrap","oop","polymorphism"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DussanFreire.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-11T03:25:24.000Z","updated_at":"2024-10-11T02:47:21.000Z","dependencies_parsed_at":"2024-11-10T11:40:45.468Z","dependency_job_id":"4fdb6151-5524-4eff-9f46-554eac7736bd","html_url":"https://github.com/DussanFreire/OOP-Polymorphism__Example-in-C-sharp","commit_stats":null,"previous_names":["dussanfreire/oop-polymorphism__example-in-c-sharp"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DussanFreire%2FOOP-Polymorphism__Example-in-C-sharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DussanFreire%2FOOP-Polymorphism__Example-in-C-sharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DussanFreire%2FOOP-Polymorphism__Example-in-C-sharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DussanFreire%2FOOP-Polymorphism__Example-in-C-sharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DussanFreire","download_url":"https://codeload.github.com/DussanFreire/OOP-Polymorphism__Example-in-C-sharp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240581422,"owners_count":19824139,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cshrap","oop","polymorphism"],"created_at":"2024-11-10T11:33:52.311Z","updated_at":"2025-02-25T00:32:13.863Z","avatar_url":"https://github.com/DussanFreire.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Company Polymorphism Example in C#\n\nThis project demonstrates the concept of **polymorphism** in C# using a company structure, where various roles (CEO, Auditor, Department Director, etc.) are represented as classes inheriting from a common base and implementing shared interfaces.\n\n## Project Overview\n\nThe project includes:\n\n- **Interfaces**: `IBaseEmployee`, `IClient`, `ICompanyStaff`, and `IPerson`.\n- **Base Classes**: `Employee`, `Manager`, and `Client`.\n- **Derived Classes**: `CEO`, `Auditor`, `DepartmentDirector`.\n- **Company Class**: Manages the company’s staff and clients, allowing for operations like adding new members and displaying their information.\n\n### Key Concepts Demonstrated\n1. **Polymorphism**: Classes like `CEO`, `Auditor`, and `DepartmentDirector` inherit from `Manager` or `Employee` and implement abstract methods in their own way.\n2. **Interfaces**: Interfaces such as `IClient`, `ICompanyStaff`, and `IBaseEmployee` enforce a contract for shared methods and properties across different classes.\n3. **Abstraction**: Abstract classes such as `Employee` and `Manager` provide a base for common behaviors while requiring derived classes to provide specific implementations.\n4. **Encapsulation**: Class properties like `Position`, `Salary`, and `Department` are encapsulated with getters and setters, ensuring controlled access.\n\n## Classes and Interfaces\n\n### Interfaces\n- **`IPerson`**: A base interface for all people-related entities.\n- **`IClient`**: Extends `IPerson` and includes client-specific properties like `Email` and `TelephoneNumber`.\n- **`IBaseEmployee`**: Provides the basic structure for employee roles, including properties like `Position` and `Salary`, and a method `ReceiveSalary()`.\n- **`ICompanyStaff`**: Combines `IPerson` and `IBaseEmployee`, and adds the `DisplayInformation()` method for staff members.\n\n### Abstract Classes\n- **`Employee`**: An abstract class defining common properties for all employees, such as `Id`, `Name`, `Position`, `Salary`, and methods like `ReceiveSalary()`, `Work()`, and `DisplayInformation()`.\n- **`Manager`**: An abstract class inheriting from `Employee` and adding manager-specific methods like `ControlTheProcess()`.\n\n### Concrete Classes\n- **`Client`**: Implements `IClient`, representing a company's client.\n- **`Auditor`**: Extends `Employee` to represent a specific type of employee responsible for auditing.\n- **`CEO`**: Inherits from `Manager`, representing the highest role in the company.\n- **`DepartmentDirector`**: Inherits from `Manager` and represents a director responsible for a department in the company.\n\n## Example Usage\n\n### Creating a Company and Adding Staff\n\n```csharp\nusing Company;\n\nCompany company = new Company();\n\n// Creating staff\nCEO ceo = new CEO { Id = 1, Name = \"John Doe\", Gender = \"Male\" };\nAuditor auditor = new Auditor { Id = 2, Name = \"Jane Smith\", Gender = \"Female\" };\nDepartmentDirector director = new DepartmentDirector { Id = 3, Name = \"Alex Brown\", Gender = \"Non-binary\" };\n\n// Adding staff to the company\ncompany.AddNewMemberToTheStaff(ceo);\ncompany.AddNewMemberToTheStaff(auditor);\ncompany.AddNewMemberToTheStaff(director);\n\n// Displaying staff information\ncompany.DisplayCompanyStafInformation();\n```\n\n### Sample Output\n\n``` bash\n*************************COMPANY STAFF*********************\n*****MANAGER********\nPosition: CEO\nName: John Doe\nSalary: 8000\n********************\n******EMPLOYEE********\nName: Jane Smith\nSalary: 3000\nPosition: Auditor\n**********************\n*****MANAGER********\nPosition: Departament Director\nName: Alex Brown\nSalary: 5000\nDepartament: Financial\n********************\n***********************************************************\n```\n\n### How to Run\n\n1.\tClone this repository to your local machine.\n2.\tOpen the solution in Visual Studio or your preferred C# development environment.\n3.\tRun the project to see the polymorphism in action.\n\n### Features\n\n* Staff Management: Easily add and manage different types of employees and clients.\n* Flexible Hierarchy: Use polymorphism to extend the company structure and create new roles as needed.\n* Console Output: Display information about staff members dynamically through the DisplayCompanyStafInformation() method.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdussanfreire%2Foop-polymorphism__example-in-c-sharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdussanfreire%2Foop-polymorphism__example-in-c-sharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdussanfreire%2Foop-polymorphism__example-in-c-sharp/lists"}