Skip to content

Ejercicio terminado #26

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
3 changes: 3 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.

38 changes: 38 additions & 0 deletions Employee.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
public class Employee {
private String name;
private String email;
private int age;
private int salary;

public Employee(String name, String email, int age, int salary){
this.setName(name);
this.setEmail(email);
this.setAge(age);
this.setSalary(salary);
}

public String getName(){
return this.name;
}
public void setName(String name){
this.name=name;
}
public String getEmail(){
return this.email;
}
public void setEmail(String email){
this.email=email;
}
public int getAge(){
return this.age;
}
public void setAge(int age){
this.age=age;
}
public int getSalary(){
return this.salary;
}
public void setSalary(int salary){
this.salary=salary;
}
}
15 changes: 15 additions & 0 deletions Intern.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
public class Intern extends Employee{
public Intern(String name, String email, int age, int salary) {
super(name, email, age, salary);
}

@Override
public void setSalary(int salary) {
if (salary>20000){
System.out.println("Lo siento, el límite es 20000");
super.setSalary(20000);
} else {
super.setSalary(salary);
}
}
}
35 changes: 35 additions & 0 deletions Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

public class Main {
public static void main(String[] args) throws IOException {
Intern intern1 = new Intern("Lucas", "locasmail", 40, 1234);
Intern intern2 = new Intern("Ana", "anemail", 35, 11345);
Intern intern3 = new Intern("Juan", "juanmail", 25, 1456);
Intern intern4 = new Intern("Sofia", "sofiaemail", 28, 11567);
Intern intern5 = new Intern("Pedro", "pedroemail", 30, 1678);
Intern intern6 = new Intern("Marta", "martaemail", 22, 21789);
Intern intern7 = new Intern("Carlos", "carlosmail", 32, 41890);
Intern intern8 = new Intern("Laura", "lauraemail", 27, 21901);
Intern intern9 = new Intern("Fernando", "fernandomail", 29, 2012);
Intern intern10 = new Intern("Elena", "elenamail", 31, 2123);

Intern[] interns = {
intern1, intern2,
intern3, intern4,
intern5, intern6,
intern7, intern8,
intern9, intern10};

var employeesFile= new FileWriter("employees.txt",true);

for( Intern intern : interns){
employeesFile.write("Name: " + intern.getName() + "\n"
+ "email: " + intern.getEmail() + "\n"
+ "age: " + intern.getAge() + "\n"
+ "salary: " + intern.getSalary() + "\n" + "==============="+ "\n");
}
employeesFile.close();
}
}
50 changes: 50 additions & 0 deletions employees.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
Name: Lucas
email: locasmail
age: 40
salary: 1234
===============
Name: Ana
email: anemail
age: 35
salary: 11345
===============
Name: Juan
email: juanmail
age: 25
salary: 1456
===============
Name: Sofia
email: sofiaemail
age: 28
salary: 11567
===============
Name: Pedro
email: pedroemail
age: 30
salary: 1678
===============
Name: Marta
email: martaemail
age: 22
salary: 20000
===============
Name: Carlos
email: carlosmail
age: 32
salary: 20000
===============
Name: Laura
email: lauraemail
age: 27
salary: 20000
===============
Name: Fernando
email: fernandomail
age: 29
salary: 2012
===============
Name: Elena
email: elenamail
age: 31
salary: 2123
===============

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