Skip to content

LabDone #23

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 2 commits 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
5 changes: 5 additions & 0 deletions Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
public class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
}
}
57 changes: 57 additions & 0 deletions src/Employee.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
public class Employee {
private String name;
private String email;
private int age;
private double 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 +
'}';
}

public Employee(String name, String email, int age, double salary) {
this.name = name;
this.email = email;
this.age = age;
this.salary = salary;


}
}
13 changes: 13 additions & 0 deletions src/Interns.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
public class Interns extends Employee {

public Interns(String name, String email, int age, double salary) {
super(name, email, age, salary);


if (salary >= 20000)
System.out.println(salary);
else System.out.println("invalid salary");

}

}
49 changes: 49 additions & 0 deletions src/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import org.w3c.dom.ls.LSOutput;

import javax.xml.namespace.QName;
import java.io.FileWriter;
import java.io.IOException;
import java.sql.SQLOutput;
import java.util.ArrayList;
import java.util.List;

public class Main {
public static void main(String[] args) throws IOException {
System.out.println("Hello world!");

Employee employee1 = new Employee("Joe", "joe@mail;com", 35, 35000);
System.out.println(employee1.getName()+ " - " + employee1.getEmail()+ " - " + employee1.getAge() + " - " + employee1.getSalary());

System.out.println(employee1);
Employee employee2 = new Employee("Maria", "maria@mail;com", 45, 38000);
Employee employee3 = new Employee("Paul", "paul@mail;com", 55, 58000);
Employee employee4 = new Employee("Bob", "bob@mail;com", 42, 35050);
Employee employee5 = new Employee("Isa", "isa@mail;com", 29, 29000);
Employee employee6 = new Employee("Brahim", "brahim@mail;com", 25, 24000);
Employee employee7 = new Employee("Natalia", "natalia@mail;com", 31, 42000);
Employee employee8 = new Employee("Ionis", "ionis@mail;com", 58, 62000);
Employee employee9 = new Employee("Sou", "sou@mail;com", 34, 40000);
Employee employee10 = new Employee("Jack", "jack@mail;com", 49, 62000);

List<Employee> employeeList = new ArrayList<>();
employeeList.add(employee1);
employeeList.add(employee2);
employeeList.add(employee3);
employeeList.add(employee4);
employeeList.add(employee5);
employeeList.add(employee6);
employeeList.add(employee7);
employeeList.add(employee8);
employeeList.add(employee9);
employeeList.add(employee10);
System.out.println(employeeList);

FileWriter fileWriter = new FileWriter ("Employees.txt", true);
for (Employee employee : employeeList) {
fileWriter.write(employee.getName() + " - " + employee.getEmail() + " - " +employee.getAge() + " - " + employee.getSalary() + "\n");
}
fileWriter.close();

}

}