Skip to content

Lab 1.06 complete #29

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.

60 changes: 60 additions & 0 deletions Employee.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
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;
}


// Getters + Setters
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 +
'\n';
}
}

16 changes: 16 additions & 0 deletions Intern.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
public class Intern extends Employee{
private final boolean Intern = true;

public Intern(String name, String email, int age, double salary) {
super(name, email, age, salary);
final int interMaxSalary = 20000;
if (salary > interMaxSalary){
setSalary(interMaxSalary);
}
}

@Override
public double getSalary() {
return super.getSalary();
}
}
52 changes: 52 additions & 0 deletions Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;


public class Main {
public static void main(String[] args) throws IOException {
System.err.println("Lab 106");

//FILE HANDLING
String direccionFichero = "out/production/lab-java-standard-input-and-classes/.idea/employees.txt";
System.out.println(direccionFichero);

File employees = new File(direccionFichero);
//makes file


FileWriter fileWriter = new FileWriter(direccionFichero, false);


//create employees
Employee employee = new Employee("Karl", "[email protected]", 22,124430);
Employee employee1 = new Employee("Jimmy", "[email protected]", 24,22000);
Employee employee2 = new Employee("Jay", "[email protected]", 25,20400);
Employee employee3 = new Employee("Jackson", "[email protected]", 32,22000);
Employee employee4 = new Employee("Junior", "[email protected]", 42,23300);
Employee employee5 = new Employee("Sam", "[email protected]", 22,20323.45);
Employee employee6 = new Employee("Karlton", "[email protected]", 52,33000);
Employee employee7 = new Employee("Kimmy", "[email protected]", 42,23003.12);
Intern intern0 = new Intern("Kroll", "[email protected]", 23,19540.43);
Intern intern1 = new Intern("Dean", "[email protected]", 22,20640.69);

// System.out.println(employee1); // checks Objects created correctly

ArrayList<Employee> employeeArrayList = new ArrayList<>();
employeeArrayList.add(employee);
employeeArrayList.add(employee1);
employeeArrayList.add(employee2);
employeeArrayList.add(employee3);
employeeArrayList.add(employee4);
employeeArrayList.add(employee5);
employeeArrayList.add(employee6);
employeeArrayList.add(employee7);
employeeArrayList.add(intern0);
employeeArrayList.add(intern1);


fileWriter.write(employeeArrayList.toString());
fileWriter.close();
}
}

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.

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