Question

In: Computer Science

Q3) Design a class for saving data of employee, the class should have multiple constructors (constructor...

Q3) Design a class for saving data of employee, the class should have multiple constructors (constructor overloading) for initializing objects with different parameters. The employee class should have different functions for saving and updating bio-data, educational background, and current status like experience, Salary, position & travel history. The employee class should have a function which asks user what do he likes to see about employee (.i.e., Bio-data, current status....) and only show the respective data. Create two objects of interns and shows their educational background, five employees and show their experience to help decide which two should be called for promotions interviews and print data of all employees who left the organization.

Solutions

Expert Solution

This is General Class Design ...... created in Eclipse.

package employeeRecord;

import java.util.ArrayList;

public class Employee {

   String EmpName, EmpDept;
   int EmpID, EmpSalary;

   public Employee(String empName, String empDept, int empID, int empSalary) {

       EmpName = empName;
       EmpDept = empDept;
       EmpID = empID;
       EmpSalary = empSalary;

   }

   // Add details Accordingly --- Employeee Objects list Can also be created using
   // utility Class

   Employee Emp1 = new Employee(EmpName, EmpDept, EmpID, EmpSalary);
   Employee Emp2 = new Employee(EmpName, EmpDept, EmpID, EmpSalary);
   Employee Emp3 = new Employee(EmpName, EmpDept, EmpID, EmpSalary);
   Employee Emp4 = new Employee(EmpName, EmpDept, EmpID, EmpSalary);
   Employee Emp5 = new Employee(EmpName, EmpDept, EmpID, EmpSalary);

   // Constructor Overloading
   Employee(int empSalary) {
       EmpSalary = empSalary;
   }

   public void AddEmployeeDetails() {
       /*
       * ......
       *
       * Code for Adding Details of employee ---- experience, Salary, position &
       * travel history----
       */
   };

   public void UpdateEmployeeDetails() {
       /*
       * ......
       *
       * Code for Adding Details of employee ---- experience, Salary, position &
       * travel history----
       */
   };

   public void EmployeeStatusReport() {

       // Can Add Switch statement to develop a console asking
       // various details mentioned in the Case Statement.

   }

   public void OldEmployeeLIst() {

   }

   public void Promotion() {

       // Set Criteria for promotion of the list of Employees

   }

}

---------------

package employeeRecord;

public class Intern {

   String InternName, InternDept;
   int InternID, InternSalary;

   public Intern() {

       // General Constructor

   };

   public Intern(String internName, String internDept, int internID, int internSalary) {
       super();
       InternName = internName;
       InternDept = internDept;
       InternID = internID;
       InternSalary = internSalary;
   }

   public void ADDnUpdateInternDetails() {
       // TODO Auto-generated method stub
       // Function to Add Educational Background of the Intern....

   }

   // Intern Object
   Intern Ravi = new Intern();
   Intern Sachin = new Intern();

}

If any Doubt do Comment, I will surely reply Do Rate.... :)


Related Solutions

Define the exception class called TornadoException. The class should have two constructors including one default constructor....
Define the exception class called TornadoException. The class should have two constructors including one default constructor. If the exception is thrown with the default constructor, the method getMessage should return "Tornado: Take cover immediately!" The other constructor has a single parameter, m, of int type. If the exception is thrown with this constructor, the getMessage should return "Tornado: m miles away; and approaching!" Write a Java program to test the class TornadoException.
In Angel, you will find a class called Employee. This class should include a constructor which...
In Angel, you will find a class called Employee. This class should include a constructor which sets name to blanks and salary to $0.00 and a constructor which sets name to a starting name and salary to a set amount. Additionally, the class should include methods to set the name and salary and return the name and salary. Create another method to return the name and salary nicely formatted as a string (hint – research the toString method). You will...
In Angel, you will find a class called Employee. This class should include a constructor which...
In Angel, you will find a class called Employee. This class should include a constructor which sets name to blanks and salary to $0.00 and a constructor which sets name to a starting name and salary to a set amount. Additionally, the class should include methods to set the name and salary and return the name and salary. Create another method to return the name and salary nicely formatted as a string (hint – research the toString method). You will...
Design a class named Employee. The class should keep the following information in fields: ·         Employee...
Design a class named Employee. The class should keep the following information in fields: ·         Employee name ·         Employee number in the format XXX–L, where each X is a digit within the range 0–9 and the L is a letter within the range A–M. ·         Hire date Write one or more constructors and the appropriate accessor and mutator methods for the class. Next, write a class named ProductionWorker that inherits from the Employee class. The ProductionWorker class should have fields...
Design a class named Employee. The class should keep the following information in fields: ·         Employee...
Design a class named Employee. The class should keep the following information in fields: ·         Employee name ·         Employee number in the format XXX–L, where each X is a digit within the range 0–9 and the L is a letter within the range A–M. ·         Hire date Write one or more constructors and the appropriate accessor and mutator methods for the class. Next, write a class named ProductionWorker that inherits from the Employee class. The ProductionWorker class should have fields...
Design and implement a class Rectangle to represent a rectangle. You should provide two Constructors for...
Design and implement a class Rectangle to represent a rectangle. You should provide two Constructors for the class, the first being the default constructor and the second which takes the basic dimensions and sets up the private member variables with the appropriate initial values. Methods should be provided that allow a user of the class to find out the length, width, area and perimeter of the shape plus a toString()method to print the values of the basic dimensions. Now implement...
In C++ a class can have multiple constructors, but only one destructor. Explain why this is...
In C++ a class can have multiple constructors, but only one destructor. Explain why this is the case using code to highlight why.
Write a class "car" with data fields "make" and "speed." The constructor should accept the "make"...
Write a class "car" with data fields "make" and "speed." The constructor should accept the "make" parameter. Be sure to use the "this" reference when setting the "make" parameter. The class should contain a static field for defaultSpeed set to 50. The class "car" should have a method "speed." The method should return the defaultSpeed. There should be an overloaded method for speed that takes a speed parameter. Finally, this class should take a getSpeed method that returns the speed....
JAVA The class will have a constructor BMI(String name, double height, double weight). The class should...
JAVA The class will have a constructor BMI(String name, double height, double weight). The class should have a public instance method, getBMI() that returns a double reflecting the person's BMI (Body Mass Index = weight (kg) / height2 (m2) ). The class should have a public toString() method that returns a String like Fred is 1.9m tall and is 87.0Kg and has a BMI of 24.099722991689752Kg/m^2 (just print the doubles without special formatting). Implement this class (if you wish you...
Class Exercise: Constructor using JAVA Let’s define a Class together and have a constructor while at...
Class Exercise: Constructor using JAVA Let’s define a Class together and have a constructor while at it. - What should the Class object represent? (What is the “real life object” to represent)? - What properties should it have? (let’s hold off on the methods/actions for now – unless necessary for the constructor) - What should happen when a new instance of the Class is created? - Question: What are you allowed to do in the constructor? - Let’s test this...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT