Question: task 1. Create an employee Class that encapsulates the concept of an employee. The attributes of an employee are: - id o a random integer

task 1.

Create an employee Class that encapsulates the concept of an employee. The attributes of an employee are: - id o a random integer in the range 0 to 999,999,999 inclusive o modify your code that generates the id value to insure that duplicate id values do not occur. o we will be using the id attribute as the key value and we want this key to be unique - name o a String of a random length between 5 and 10 characters (inclusive) made up of a random set of lower case characters - dept o a random integer in the range 1 to 5 (inclusive) - hired o a random integer in the range 1995 to 2005 (inclusive)

Task 2:

Create the following classes: - TreeMap - AVLTreeMap - SplayTreeMap - RBTreeMap

Task 3: -

Create a client class that o Generates an array of 100,000 employees in random order o Create a second array of 10,000 unique integers in the range 0 to 99,999. These integer values should be in a random order. o For each of the tree map classes created in Task2 do the following: Start a timer Insert each employee object from the first array into the tree class Stop the timer and record the insertion/build time Start a timer Walk across the second array using its stored integer values as the key values (id value) to look up each entry in the tree. Stop the timer and record the search/lookup time. o Create and display a nicely formatted ASCII table that shows the insertion/build time and search/lookup time for each of the tree classes. Be sure to include the value of N as part of the table. o Consider upping N to 1,000,000/100,000 and possibly 10,000,000/1,000,000 if it appears that your program will run in a reasonable amount of time. You only need to include the result table for the highest value of N used.

I have code for task 1.

package company;

import java.util.Random;

//class employee

public class Employee{

public static int id;

public static String name;

public static int dept;

public static int hired;

public int getid();

public String getname;

public int getdept();

public int gethired();

} //end employee class

public abstract class AbstractFactory {

abstract public int getid();

abstract public String getname;

abstract public int getdept();

abstract public int gethired();

}

public class EmployeeFactory extends AbstractFactory {

public int getid() {

Random rand = new Random();

public static int emp_id=rand.nextInt(1000000000);

return emp_id }

//string name

public String getname() {

public static String name;

char[] chars = "abcdefghijklmnopqrstuvwxyz".toCharArray();

StringBuilder sb = new StringBuilder();

Random rand2 = new Random();

for (int i = 0; i < 20; i++) {

char c = chars[random2.nextInt(chars.length)];

sb.append(c); }

name = sb.toString();

return name;

}

public int getdept(){

Random rand1 = new Random();

rand1 = 1 + (int)(Math.random() * 5);

public static dept=rand1;

return dept;

}

// hired variable

public int gethired(){

Random rand3 = new Random();

rand3 = 1995 + (int)(Math.random() * 2005);

public static hired = rand3;

return hired;

}

}

public class client() {

public static void main(String args[]){

// array of 1000 employess

Employee[] myList = new Employee[1000];

for( int i=0; i<1000; i++ ) Employee [i] = new Employee();

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!