-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a308def
commit d6bb49a
Showing
16 changed files
with
182 additions
and
7 deletions.
There are no files selected for viewing
Binary file not shown.
19 changes: 19 additions & 0 deletions
19
Week5-ObjectOriented/OOPBasics/OOPBasics/Entities/Employee.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace OOPBasics.Entities | ||
{ | ||
//Inheritance | ||
public class Employee : Person | ||
{ | ||
public Employee(string name,string surname,int age,int salary):base(name,surname,age) | ||
{ | ||
Salary = salary; | ||
} | ||
|
||
public int Salary { get; set; } | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
Week5-ObjectOriented/OOPBasics/OOPBasics/Entities/Employer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace OOPBasics.Entities | ||
{ | ||
// Polymorphism with Person class | ||
// Inheritance | ||
public class Employer : Person | ||
{ | ||
public Employer(string name, string surname, int age,string degree) : base(name, surname, age) | ||
{ | ||
Degree = degree; | ||
} | ||
|
||
public string Degree { get; set; } | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
Week5-ObjectOriented/OOPBasics/OOPBasics/Entities/Person.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace OOPBasics.Entities | ||
{ | ||
public class Person | ||
{ | ||
private int _Age; | ||
//Encapsulation | ||
public int Age | ||
{ | ||
get { return _Age; } | ||
set | ||
{ | ||
if (value < 18) | ||
{ | ||
_Age = 0; | ||
} | ||
else | ||
{ | ||
_Age = value; | ||
} | ||
} | ||
} | ||
public string Name { get; set; } | ||
public string Surname { get; set; } | ||
|
||
public Person(string name,string surname,int age) | ||
{ | ||
Name = name; | ||
Surname = surname; | ||
Age = age; | ||
} | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,29 @@ | ||
using System; | ||
using OOPBasics.Entities; | ||
using OOPBasics.Services; | ||
using System; | ||
|
||
namespace OOPBasics | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
Console.WriteLine("Hello World!"); | ||
EmployerManager employerManager = new EmployerManager(); | ||
EmployeeManager employeeManager = new EmployeeManager(); | ||
|
||
Employee emp1 = employeeManager.CreateEmployee("Emre", "Kurtar", 30, 10000); | ||
Employee emp2 = employeeManager.CreateEmployee("Merve", "Kurtar", 25, 5000); | ||
employeeManager.CreateEmployee("Fatma", "Kurtar", 20, 8000); | ||
employeeManager.CreateEmployee("Can", "Kurtar", 19, 3000); | ||
|
||
Employer patron = employerManager.CreateEmployer("Patron", "Patron", 45, "Yazılım Uzmanı"); | ||
|
||
employerManager.ChangeEmployeeSalary(employeeManager.EmployeeS, "Emre", 5000); | ||
employerManager.ChangeEmployeeSalary(employeeManager.EmployeeS, "Merve","Kurtar", 1000); | ||
|
||
Console.WriteLine(emp1.Salary); | ||
Console.WriteLine(emp2.Salary); | ||
|
||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
Week5-ObjectOriented/OOPBasics/OOPBasics/Services/EmployeeManager.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using OOPBasics.Entities; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace OOPBasics.Services | ||
{ | ||
public class EmployeeManager | ||
{ | ||
public List<Employee> EmployeeS { get; set; } | ||
public EmployeeManager() | ||
{ | ||
EmployeeS = new List<Employee>(); | ||
} | ||
|
||
public Employee CreateEmployee(string name, string surname, int age, int salary) | ||
{ | ||
Employee newEmployee = new Employee(name, surname, age, salary); | ||
EmployeeS.Add(newEmployee); | ||
return newEmployee; | ||
} | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
Week5-ObjectOriented/OOPBasics/OOPBasics/Services/EmployerManager.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using OOPBasics.Entities; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace OOPBasics.Services | ||
{ | ||
public class EmployerManager | ||
{ | ||
public List<Employer> Employers { get; set; } | ||
public EmployerManager() | ||
{ | ||
Employers = new List<Employer>(); | ||
} | ||
|
||
public Employer CreateEmployer(string name,string surname,int age,string degree) | ||
{ | ||
Employer newEmployer = new Employer(name, surname, age, degree); | ||
Employers.Add(newEmployer); | ||
return newEmployer; | ||
} | ||
|
||
public void ChangeEmployeeSalary(List<Employee> employeeList,string name,int newSalary) | ||
{ | ||
if(employeeList != null) | ||
{ | ||
foreach (var item in employeeList) | ||
{ | ||
if (item.Name.Equals(name)) | ||
{ | ||
item.Salary = newSalary; | ||
Console.WriteLine(name + " 'nin maaşı " + item.Salary + " olarak değişti"); | ||
} | ||
} | ||
} | ||
} | ||
|
||
// Polymorphism with overriding function | ||
public void ChangeEmployeeSalary(List<Employee> employeeList, string name,string surname, int newSalary) | ||
{ | ||
if (employeeList != null) | ||
{ | ||
foreach (var item in employeeList) | ||
{ | ||
if (item.Name.Equals(name) && item.Surname.Equals(surname)) | ||
{ | ||
item.Salary = newSalary; | ||
Console.WriteLine(name + " 'nin maaşı " + item.Salary + " olarak değişti"); | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
} | ||
} |
Binary file modified
BIN
+3 KB
(170%)
Week5-ObjectOriented/OOPBasics/OOPBasics/bin/Debug/net5.0/OOPBasics.dll
Binary file not shown.
Binary file modified
BIN
+1.78 KB
(120%)
Week5-ObjectOriented/OOPBasics/OOPBasics/bin/Debug/net5.0/OOPBasics.pdb
Binary file not shown.
Binary file modified
BIN
+1.5 KB
(130%)
Week5-ObjectOriented/OOPBasics/OOPBasics/bin/Debug/net5.0/ref/OOPBasics.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion
2
...ectOriented/OOPBasics/OOPBasics/obj/Debug/net5.0/OOPBasics.csproj.CoreCompileInputs.cache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
d8c246f9963cb322e902c2b11a1eeddf9f72d408 | ||
5160bbfeee8bdc461d5ac90c679ae5018a0d3363 |
Binary file modified
BIN
+0 Bytes
(100%)
...jectOriented/OOPBasics/OOPBasics/obj/Debug/net5.0/OOPBasics.csprojAssemblyReference.cache
Binary file not shown.
Binary file modified
BIN
+3 KB
(170%)
Week5-ObjectOriented/OOPBasics/OOPBasics/obj/Debug/net5.0/OOPBasics.dll
Binary file not shown.
Binary file modified
BIN
+1.78 KB
(120%)
Week5-ObjectOriented/OOPBasics/OOPBasics/obj/Debug/net5.0/OOPBasics.pdb
Binary file not shown.
Binary file modified
BIN
+1.5 KB
(130%)
Week5-ObjectOriented/OOPBasics/OOPBasics/obj/Debug/net5.0/ref/OOPBasics.dll
Binary file not shown.