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

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...
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.
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...
The Person Class Uses encapsulation Attributes private String name private Address address Constructors one constructor with...
The Person Class Uses encapsulation Attributes private String name private Address address Constructors one constructor with no input parameters since it doesn't receive any input values, you need to use the default values below: name - "John Doe" address - use the default constructor of Address one constructor with all (two) parameters one input parameter for each attribute Methods public String toString() returns this object as a String, i.e., make each attribute a String, concatenate all strings and return as...
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...
Project 1 Fractional Number Class Part-1 for Five groups of member functions: Constructors (inc. string constructor)...
Project 1 Fractional Number Class Part-1 for Five groups of member functions: Constructors (inc. string constructor) Getter/setters Math Type cast Friend << and >> Part-2 for the explanation for the behavior observed by running the provided test pattern: six (6) operations in one statement vs. six (6) operations in six (6) statements. PROJECT 1 Frac Class The following information, located on Github m03, are provided as a starter. Frac.h, a complete Frac Class Declaration ( the definition is to be...
This class has two constructors. The default constructor (the one that takes no arguments) should initialize the first and last names to "None", the seller ID to "ZZZ999", and the sales total to 0.
For this assignment, implement and use the methods for a class called Seller that represents information about a salesperson.The Seller classUse the following class definition:class Seller { public:   Seller();   Seller( const char [], const char[], const char [], double );        void print();   void setFirstName( const char [] );   void setLastName( const char [] );   void setID( const char [] );   void setSalesTotal( double );   double getSalesTotal(); private:   char firstName[20];   char lastName[30];   char ID[7];   double salesTotal; };Data MembersThe data members for the class are:firstName holds the Seller's first namelastName holds the Seller's last nameID holds the Seller's id numbersalesTotal holds the Seller's sales totalConstructorsThis class has two constructors. The default constructor (the one that takes...
In C++ Write a class named TestScores. The class constructor should accept an array of test...
In C++ Write a class named TestScores. The class constructor should accept an array of test scores as its argument. The class should have a member function that returns the average of the test scores. If any test score in the array is negative or greater than 100, the class should throw an exception. Demonstrate the class in program.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT