import java.util.*;
import java.io.*;
class DuplicateEntryException
extends Exception { DuplicateEntryException
(String a
) {
detail = a;
}
{
return "User Defined Exception : "+detail;
}
}
class a1 {
{
emp_struct obj = new emp_struct();
obj.emp_id = br.readLine();
obj.name = br.readLine();
obj.
salary =
Double.
parseDouble(br.
readLine());
obj.dept = br.readLine();
try{
System.
out.
println("In try block");
// l1.addFirst(obj);
search(obj);
l1.addFirst(obj);
}catch(DuplicateEntryException e){
obj = input();
}
return obj;
}
static boolean search(emp_struct obj) throws DuplicateEntryException
{
int begIndex = 0;
for(begIndex =0;begIndex<l1.size();begIndex++)
{
emp_struct chkCase = (emp_struct)l1.get(begIndex);
String chk = chkCase.
getEmpID();
System.
out.
println(chk +
"&" +obj.
emp_id);
if(chk.equals(obj.emp_id));
throw new DuplicateEntryException("Duplicate entry found");
}
return true;
}
{
emp_struct obj;
int i=0;
for(i=0;i<10;i++)
{
obj = input();
}
}
}
class emp_struct {
public double salary;
{
return emp_id;
}
{
return emp_id+"\t"+name+"\t"+salary+"\t"+dept;
}
}