Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Task/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.example</groupId>
<artifactId>Task</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

</project>
47 changes: 47 additions & 0 deletions Task/src/main/java/org/example/Employee.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package org.example;

public class Employee {
private String name;
private String email;
private int age;
private 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 void setName(String name) {
this.name = name;
}

public String getEmail() {
return email;
}

public void setEmail(String email) {
this.email = email;
}

public int getAge() {
return age;
}

public void setAge(int age) {
this.age = age;
}

public double getSalary() {
return salary;
}

public void setSalary(double salary) {
this.salary = salary;
}
}
12 changes: 12 additions & 0 deletions Task/src/main/java/org/example/Intern.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.example;

public class Intern extends Employee{
public static final double SALARY_LIMIT = 20000;

public Intern(String name, String email, int age, double salary) {
super(name,email,age,salary);
if (salary > SALARY_LIMIT){
throw new IllegalArgumentException("The salary of an intern does not exceed 20,000");
}
}
}
34 changes: 34 additions & 0 deletions Task/src/main/java/org/example/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package org.example;

import java.io.FileWriter;
import java.io.IOException;

public class Main {
public static void main(String[] args) {
Employee[] employees = {
new Employee("Elvin Məmmədov", "[email protected]", 25, 9000),
new Employee("Nərmin Əliyeva", "[email protected]", 23, 8050),
new Employee("Orxan Həsənov", "[email protected]", 28, 11000),
new Employee("Aysel Quliyeva", "[email protected]", 24, 8000),
new Intern("Murad Əliyev", "[email protected]", 20, 9000),
new Intern("Leyla Rəhimova", "[email protected]", 21, 12000),
new Employee("Rəşad İsmayılov", "[email protected]", 31, 23000),
new Employee("Kamal Hüseynov", "[email protected]", 35, 15000),
new Employee("Zəhra Abdullayeva", "[email protected]", 22, 700),
new Employee("Günel Sadiqova", "[email protected]", 26, 99950)
};
try(FileWriter writer = new FileWriter("employees.txt")){
for(Employee employee : employees){
writer.write("Name: " + employee.getName()+ "\n");
writer.write("Email: " + employee.getEmail()+ "\n");
writer.write("Age: " + employee.getAge()+ "\n");
writer.write("Salary: " + employee.getSalary() +"\n");
writer.write("-------------------\n");
}
System.out.println("employees.txt created successfully!");

} catch (IOException e) {
throw new RuntimeException(e);
}
}
}