I have 10 rows of employee details( like employee skills, expected salary, work hours) in ArrayList. Now when the user enter employee details from frontend, all the rows should rank based on the exact match with he input.
I have tried using Comparator, but it is used to compare two objects in memory .. but i want to compare all objects in memory to the user input.
I'm stuck here since long time. Would love to here your suggestions how to solve this problem? I am new to java.
Here's what i have done. Second half of this code is full of errors and incomplete as i have not found right logic.
import java.util.*;
import java.lang.*;
import java.io.*;
public class rank {
int hours,price;
String skills,domain,location;
public rank ( int hours, int price, String skills, String domain, String location)
{
this.hours= hours;
this.price=price;
this.skills= skills;
this.domain= domain;
this.location= location;
}
public String toString()
{
return this.hours + " " + this.price+
" " + this.skills + " " + this.domain + " " + this.location;
}
public static void main(String[] args)
{
ArrayList<rank> ar = new ArrayList<rank>();
ar.add(new rank(20,30,"java,oracle","fin","hyd"));
ar.add(new rank(30,40,"oracle","fin","hyd"));
ar.add(new rank(10,40,"oracle","fin","hyd"));
ar.add(new rank(50,40,"java","fin","chn"));
System.out.println("unsorted");
for (int i=0;i<ar.size();i++)
System.out.println(ar.get(i));
Scanner input = new Scanner(System.in);
int hours1 = input.nextInt();
int price1= input.nextInt();
String skills1= input.nextLine();
String domain1= input.nextLine();
String location1=input.nextLine();
for (int j=0;j<ar.size();j++)
{
if (input == (ar.rank))
}
/*System.out.println("sorted");
Collections.sort(ar, new rankbyhours());
for (int i=0;i<ar.size();i++)
System.out.println(ar.get(i));
*/
}
}
/*class rankbyhours implements Comparator
{
public int compare(Object o1, Object o2)
{
rank r1 = (rank)o1;
input i1 = (input)o2;
}
}
*/