diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..ab1f416 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,10 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Ignored default folder with query files +/queries/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/lab-java-standard-input-and-classes.iml b/.idea/lab-java-standard-input-and-classes.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/.idea/lab-java-standard-input-and-classes.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..f5bd2df --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..398d0f7 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/out/production/lab-java-standard-input-and-classes/main/lab2.class b/out/production/lab-java-standard-input-and-classes/main/lab2.class new file mode 100644 index 0000000..366240a Binary files /dev/null and b/out/production/lab-java-standard-input-and-classes/main/lab2.class differ diff --git a/src/main/Employee.java b/src/main/Employee.java new file mode 100644 index 0000000..bfac7b5 --- /dev/null +++ b/src/main/Employee.java @@ -0,0 +1,52 @@ +package main; + +public class Employee { +protected String name; + protected String email; + protected int age; + protected double salary; + + public Employee(String name, String email, int age, double salary) { + this.name=name; + this.email= email; + this.age=age; + this.salary=salary; + } + + + public String getName(){ + return name; + +} + +public String getEmail(){ + return email; +} + +public int getAge(){ + return age; +} + +public double getSalary(){ + return salary; +} + + +public void setName(String name){ + this.name=name; + +} + public void setEmail(String email){ + this.email=email; + + } + + public void setAge(int age){ + this.age=age; + + } + + public void setSalary(double salary){ + this.salary=salary; + } +} diff --git a/src/main/Intern.java b/src/main/Intern.java new file mode 100644 index 0000000..b5bc18f --- /dev/null +++ b/src/main/Intern.java @@ -0,0 +1,31 @@ +package main; + +public class Intern extends Employee { + private final double MAX_INTERN_SALARY=20000; + + public Intern(String name, String email, int age, double salary){ super(name,email,age,salary); + if(salary>MAX_INTERN_SALARY){ + System.err.println("Intern salary should not above 20000"); + } + + } + + public void setSalary(double salary){ + if(salary>MAX_INTERN_SALARY){ + System.err.println("Intern salary should not above 20000"); + + } + else{ + super.setSalary(salary); + } + } + + public double getInternSalary(){ + return salary; + } + + public double getMAX_INTERN_SALARY(){ + return MAX_INTERN_SALARY; + } + +} diff --git a/src/main/main.java b/src/main/main.java new file mode 100644 index 0000000..123dd61 --- /dev/null +++ b/src/main/main.java @@ -0,0 +1,34 @@ +package main; + +import java.io.FileWriter; +import java.io.IOException; +import java.lang.ref.WeakReference; + +public class main { + + public static void main() throws IOException { + Employee[] employees=new Employee[10]; + employees[0]=new Employee("Yaqut","yaqut@gmail.com", 20, 3000); + + employees[1]=new Employee("Aysun","aysun@gmail.com", 20, 3000); + employees[2]=new Employee("Vusale","vusu@gmail.com", 20, 20); + employees[4]=new Employee("Nezrin","nezrin@gmail.com", 20, 2500); + employees[5]=new Employee("Murad","murad@gmail.com", 15, 1500); + employees[6]=new Employee("konbili","konbili@gmail.com", 20, 3000); + employees[7]=new Employee("gunay","gunay@gmail.com", 20, 30); + employees[8]=new Employee("nihad","nihad@gmail.com", 20, 600); + employees[9]=new Employee("emin","emin@gmail.com", 20, 700); + + try (FileWriter writer = new FileWriter("employees.txt")){ + for(int i=0; i<10; i++){ + writer.write("name"+employees[i].getName()+"\n"); + writer.write("email"+employees[i].getEmail()+ "\n"); + writer.write("age"+employees[i].getAge()+ "\n"); + writer.write("Salary"+employees[i].getSalary()+ "\n"); + + } + } + + + } +}