#include <iostream>
using namespace std;
class AbstractEmployee { //Abstract
virtual void AskForPromotion() = 0;
};
class Employee : AbstractEmployee{
//Encapsulation
string Name;
string Department;
string Relation;
int Experience;
int Age;
public:
void setName(string name){
Name = name;
}
string getName(){
return Name;
}
void setDepartment(string department){
Department = department;
}
string getDepartment(){
return Department;
}
void setRelation(string relation){
Relation = relation;
}
string getRelation(){
return Relation;
}
void setExperience(int experience){
Experience = experience;
}
int getExperience(){
return Experience;
}
void setAge(int age){
if(age >= 18)
Age = age;
}
int getAge(){
return Age;
}
void IntroduceYourself() {
cout << "Name: " << Name << endl;
cout << "Department: " << Department << endl;
cout << "Relation: " << Relation << endl;
cout << "Experience: " << Experience << endl;
cout << "Age: " << Age << endl;
}
Employee(string name, string department, string relation, int experience, int age) {
Name = name;
Department = department;
Relation = relation;
Experience = experience;
Age = age;
}
void AskForPromotion() {
if(Age >= 25 && Relation == "Good" && Experience >= 3)
cout << Name << " , you got promoted! Yaaay." << endl;
else
cout << "Sorry " << Name << " , your promotion is denied..." << endl;
}
};
int main(){
Employee emp1 = Employee("Gorkem", "IT", "Good", 2, 27);
Employee emp2 = Employee("Furkan", "Web", "Good", 3, 28);
emp1.AskForPromotion();
emp2.AskForPromotion();
return 0;
}
Ayni class içerisinde kullanman lazim.
Aslında bu constructor olmadığı zamanlarda değişkenlerin isimlerini ve özelliklerini değiştirip get ile alabildiğimiz bir yol mu?
Oyle olunca dogrudan ulasamiyorsun o sebeple setter ve getter kullanman lazim. PHP'de mantik bu sekilde mi isliyor bilmiyorum.
Bu sitenin çalışmasını sağlamak için gerekli çerezleri ve deneyiminizi iyileştirmek için isteğe bağlı çerezleri kullanıyoruz.