Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.nio.file.FileSystemLoopException;
- import java.util.HashMap;
- import java.util.Map;
- import java.util.TreeMap;
- import static java.lang.System.in;
- public class Employee {
- String name;
- double salary;
- String position;
- String department;
- String email = "n/a";
- String age = "-1";
- public Employee(String name, double salary, String position, String department){
- this.name = name;
- this.salary = salary;
- this.position = position;
- this.department = department;
- }
- public Employee(String name, double salary, String position, String department, String email, String age) {
- this.name = name;
- this.salary = salary;
- this.position = position;
- this.department = department;
- this.email = email;
- this.age = age;
- }
- public Employee(String name, double salary, String position, String department, String age){
- this.name = name;
- this.salary = salary;
- this.position = position;
- this.department = department;
- this.age = age;
- }
- public static void main(String[] args) throws IOException {
- BufferedReader reader = new BufferedReader(new InputStreamReader(in));
- Map<String, Employee> map = new HashMap<>();
- Map<String, TreeMap<Double, Integer>> devMap = new HashMap<>();
- TreeMap<Double, Integer> innerMap = new TreeMap<>();
- int n = Integer.parseInt(reader.readLine());
- for (int i = 0; i <n ; i++) {
- String[] line = reader.readLine().split(" ");
- String name = line[0];
- double salary = Double.parseDouble(line[1]);
- String position = line[2];
- String development = line[3];
- if(line.length == 4){
- Employee employee = new Employee(name, salary, position, development);
- map.put(name, employee);
- } else if (line.length == 6){
- String email = line[4];
- String age = line[5];
- Employee employee = new Employee(name, salary, position, development, email, age);
- map.put(name, employee);
- } else if (line.length == 5){
- try {
- int number = Integer.parseInt(line[4]);
- String age = line[4];
- Employee employee = new Employee(name, salary, position, development, age);
- map.put(name, employee);
- } catch (Exception ex ){
- String email = line[4];
- Employee employee = new Employee(name, salary, position, development, email);
- map.put(name, employee);
- }
- }
- }
- // if (!devMap.containsKey(development)){
- // devMap.put(development, innerMap);
- // }
- // if (!innerMap.containsKey(salary)){
- // innerMap.put(salary, 0);
- // }
- // devMap.put(development, innerMap);
- System.out.println( );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement