Skip to content

created employee.txt #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
10 changes: 10 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions .idea/lab-java-standard-input-and-classes.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 58 additions & 0 deletions Lab/Employee.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package Lab;

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 "Employee{" +
"name='" + name + '\'' +
", email='" + email + '\'' +
", age=" + age +
", salary=" + salary +
'}';
}
}
23 changes: 23 additions & 0 deletions Lab/Intern.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package Lab;

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

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) {
throw new IllegalArgumentException("El salario del becario no puede superar los " + SALARY_LIMIT);
}
return salary;
}

@Override
public void setSalary(double salary) {
if (salary > SALARY_LIMIT) {
throw new IllegalArgumentException("El alario del becario no puede superar los "+SALARY_LIMIT);
}
}
}
37 changes: 37 additions & 0 deletions Lab/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package Lab;

import javax.sound.midi.Soundbank;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.util.ArrayList;
import java.util.List;

public class Main {
public static void main(String[] args) {
List<Employee> employees = new ArrayList<>();

employees.add(new Employee("Luis Pérez", "[email protected]", 30, 35000));
employees.add(new Employee("Ana Gómez", "[email protected]", 28, 40000));
employees.add(new Intern("Carlos Ruiz", "[email protected]", 21, 18000));
employees.add(new Employee("Sofía López", "[email protected]", 35, 50000));
employees.add(new Intern("Lucía Díaz", "[email protected]", 22, 20000));
employees.add(new Employee("Miguel Torres", "[email protected]", 40, 45000));
employees.add(new Employee("Paula Moreno", "[email protected]", 33, 38000));
employees.add(new Intern("Jorge Ramírez", "[email protected]", 23, 19500));
employees.add(new Employee("Elena Sánchez", "[email protected]", 29, 41000));
employees.add(new Intern("David Castro", "[email protected]", 24, 19000));

try(BufferedWriter writer=new BufferedWriter(new FileWriter("employee.txt"))) {
for(Employee e:employees){
writer.write(e.toString());
writer.newLine();
}
System.out.println("archivo Employee creado Correctamente");
}catch (Exception e){
System.err.println("Error al escribir el archivo "+e.getMessage());
}



}
}
10 changes: 10 additions & 0 deletions employee.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Employee{name='Luis Pérez', email='[email protected]', age=30, salary=35000.0}
Employee{name='Ana Gómez', email='[email protected]', age=28, salary=40000.0}
Employee{name='Carlos Ruiz', email='[email protected]', age=21, salary=18000.0}
Employee{name='Sofía López', email='[email protected]', age=35, salary=50000.0}
Employee{name='Lucía Díaz', email='[email protected]', age=22, salary=20000.0}
Employee{name='Miguel Torres', email='[email protected]', age=40, salary=45000.0}
Employee{name='Paula Moreno', email='[email protected]', age=33, salary=38000.0}
Employee{name='Jorge Ramírez', email='[email protected]', age=23, salary=19500.0}
Employee{name='Elena Sánchez', email='[email protected]', age=29, salary=41000.0}
Employee{name='David Castro', email='[email protected]', age=24, salary=19000.0}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading