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/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..653c2cb --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..8abc343 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..712ab9d --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file 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..d6ebd48 --- /dev/null +++ b/.idea/lab-java-standard-input-and-classes.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..d1e1729 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ 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/Lab2/pom.xml b/Lab2/pom.xml new file mode 100644 index 0000000..f4447fe --- /dev/null +++ b/Lab2/pom.xml @@ -0,0 +1,17 @@ + + + 4.0.0 + + org.ironhack.envsetup + Lab2 + 1.0-SNAPSHOT + + + 17 + 17 + UTF-8 + + + \ No newline at end of file diff --git a/Lab2/src/main/java/org/ironhack/envsetup/Employee.java b/Lab2/src/main/java/org/ironhack/envsetup/Employee.java new file mode 100644 index 0000000..4c52e49 --- /dev/null +++ b/Lab2/src/main/java/org/ironhack/envsetup/Employee.java @@ -0,0 +1,31 @@ +package org.ironhack.envsetup; +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; } + + @Override + public String toString() { + return name + ", " + email + ", " + age + ", " + salary; + } +} \ No newline at end of file diff --git a/Lab2/src/main/java/org/ironhack/envsetup/Intern.java b/Lab2/src/main/java/org/ironhack/envsetup/Intern.java new file mode 100644 index 0000000..0b3560e --- /dev/null +++ b/Lab2/src/main/java/org/ironhack/envsetup/Intern.java @@ -0,0 +1,21 @@ +package org.ironhack.envsetup; +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,validateSalary(salary)); + } + + private static double validateSalary(double salary) { + if (salary > SALARY_LIMIT) { + System.out.println("Salary exceeds intern limit. Setting to " + SALARY_LIMIT); + return SALARY_LIMIT; + } + return salary; + } + + @Override + public void setSalary(double salary) { + super.setSalary(validateSalary(salary)); + } +} \ No newline at end of file diff --git a/Lab2/src/main/java/org/ironhack/envsetup/Main.java b/Lab2/src/main/java/org/ironhack/envsetup/Main.java new file mode 100644 index 0000000..5cc0032 --- /dev/null +++ b/Lab2/src/main/java/org/ironhack/envsetup/Main.java @@ -0,0 +1,32 @@ +package org.ironhack.envsetup; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.ArrayList; + +public class Main { + public static void main(String[] args) { + ArrayList employees = new ArrayList<>(); + + employees.add(new Employee("Alice", "alice@email.com", 30, 50000)); + employees.add(new Employee("Bob", "bob@email.com", 28, 48000)); + employees.add(new Intern("Charlie", "charlie@email.com", 22, 25000)); + employees.add(new Intern("Daisy", "daisy@email.com", 21, 18000)); + employees.add(new Employee("Elena", "elena@email.com", 27, 47000)); + employees.add(new Employee("Frank", "frank@email.com", 35, 52000)); + employees.add(new Intern("George", "george@email.com", 23, 19000)); + employees.add(new Intern("Hannah", "hannah@email.com", 21, 22000)); + employees.add(new Employee("Ian", "ian@email.com", 40, 60000)); + employees.add(new Employee("Jane", "jane@email.com", 29, 48000)); + + + try (PrintWriter writer = new PrintWriter(new FileWriter("employees.txt"))) { + for (Employee emp : employees) { + writer.println(emp); + } + System.out.println("Employees written to employees.txt"); + } catch (IOException e) { + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/Lab2/target/classes/org/ironhack/envsetup/Employee.class b/Lab2/target/classes/org/ironhack/envsetup/Employee.class new file mode 100644 index 0000000..c4e79dc Binary files /dev/null and b/Lab2/target/classes/org/ironhack/envsetup/Employee.class differ diff --git a/Lab2/target/classes/org/ironhack/envsetup/Intern.class b/Lab2/target/classes/org/ironhack/envsetup/Intern.class new file mode 100644 index 0000000..7aa9f73 Binary files /dev/null and b/Lab2/target/classes/org/ironhack/envsetup/Intern.class differ diff --git a/Lab2/target/classes/org/ironhack/envsetup/Main.class b/Lab2/target/classes/org/ironhack/envsetup/Main.class new file mode 100644 index 0000000..1a24735 Binary files /dev/null and b/Lab2/target/classes/org/ironhack/envsetup/Main.class differ diff --git a/employees.txt b/employees.txt new file mode 100644 index 0000000..c03278e --- /dev/null +++ b/employees.txt @@ -0,0 +1,4 @@ +Alice, alice@email.com, 30, 50000.0 +Bob, bob@email.com, 28, 48000.0 +Charlie, charlie@email.com, 22, 20000.0 +Daisy, daisy@email.com, 21, 18000.0