Using C++,
Write a class named Employee that has the following member variables:
name. A string that holds the employee's name.
idNumber. An int variable that holds the employee's ID number.
department. A string that holds the name of the department where the employee works.
position. A string that holds the employee's job title.
The class should have the following constructors:
A constructor that accepts the following values as arguments and assigns them to the appropriate member variables: employee's name, employee's ID number, department, and position.
A constructor that accepts the following values as arguments and assigns them to the appropriate member variables: employee's name and ID number. The department and position fields should be assigned an empty string ("").
A default constructor that assigns empty strings ("") to the name, department, and position member variables, and 0 to the idNumber member variable.
Write appropriate mutator functions that store values in these member variables and accessor functions that return the values in these member variables. Once you have written the class, write a separate program that creates three Employee objects to hold the following data using the above 3 constructors (first constructor for first name, 2nd constructor for 2nd name and 3rd constructor for 3rd name).
Name | ID Number | Department | Position |
---|---|---|---|
Paul Rogers | 12345 | Accounting | Vice President |
John Reid | 34567 | IT | Programmer |
Peter Meyers | 47899 | Manufacturing | Engineer |
The program should store this data in the three objects and then display the data for each employee on the screen.
Sample Run Name: Paul Rogers ID Number: 12345 Department: Accounting Position: Vice President Name: John Reid ID Number: 34567 Department: IT Position: Programmer Name: Peter Meyers ID Number: 47899 Department: Manufacturing Position: Engineer
HI, Please find my implementation.
Please let me know in case of any issue.
public class Employee {
// instance variables
private String name;
private int idNumber;
private String department;
private String position;
// constructor
public Employee() {
this.name = "";
this.idNumber = 0;
this.department = "";
this.position = "";
}
/**
* @param name
* @param idNumber
* @param department
* @param position
*/
public Employee(String name, int idNumber, String department, String position) {
this.name = name;
this.idNumber = idNumber;
this.department = department;
this.position = position;
}
//getters and setters
/**
* @return name
*/
public String getName() {
return name;
}
/**
* @return idNumber
*/
public int getIdNumber() {
return idNumber;
}
/**
* @return department
*/
public String getDepartment() {
return department;
}
/**
* @return position
*/
public String getPosition() {
return position;
}
/**
* @param name
*/
public void setName(String name) {
this.name = name;
}
/**
* @param idNumber
*/
public void setIdNumber(int idNumber) {
this.idNumber = idNumber;
}
/**
* @param department
*/
public void setDepartment(String department) {
this.department = department;
}
/**
* @param position
*/
public void setPosition(String position) {
this.position = position;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return "Name: "+name+"\nID Number: "+idNumber+"\nDepartment: "+department+"\nPosition: "+position+"\n";
}
}
#############
public class EmployeeTest {
public static void main(String[] args) {
// creating two object of Employee
Employee emp1 = new Employee();
emp1.setName("Pravesh Kumar");
emp1.setIdNumber(12);
emp1.setDepartment("CSE");
emp1.setPosition("SSE");
Employee emp2 = new Employee("Alex", 13, "EEE", "Maneger");
System.out.println(emp1);
System.out.println(emp2);
}
}
/*
Sample run:
Name: Pravesh Kumar
ID Number: 12
Department: CSE
Position: SSE
Name: Alex
ID Number: 13
Department: EEE
Position: Maneger
*/
Using C++, Write a class named Employee that has the following member variables: name. A string...
Write a C++ program Write a class named Employee that has the following member variables: name A string that holds the employee name idNumber An int to hold employee id number department A string to hold the name of the department position A string to hold the job position The class will have three constructors: 1. A constructor that accepts all the internal data such as: Employee susan("Susan Meyers", 47899, "Accounting", "Vice President"); 2. A constructor that accepts some of...
It must be C++ Chapter 13 Programming Challenge 2: Employee Class. See instruction: Chapter 13 Programming Challenge 2 Employee Class.pdf Program Template: // Chapter 13, Programming Challenge 2: Employee Class #include <iostream> #include <string> using namespace std; // Employee Class Declaration class Employee { private: string name; // Employee's name int idNumber; // ID number string department; // Department name string position; // Employee's position public: // TODO: Constructors // TODO: Accessors // TODO: Mutators }; // Constructor #1 Employee::Employee(string...
Create a C# Console program. Add a class named Employee that has the following public fields: • Name. The name field references a String object that holds the employee’s name. • IDNumber. The IDNumber is an int that holds the employee’s ID number. • Department. The department field is a String that holds the name of the department where the employee works. • Position. The position field is a String that holds the employee’s job title. Once you have written...
Create a c++ code and answer number 1 Homework Ch. 13 - Employee Class 30 points Design a class named Employee that has the following attributes: * Name ID Number- (Employee's] Identification Number " Department-the name of the department where the employee works " Position-the employee's job title The class should have the following constructors: A constructor that accepts values for all the member data as arguments A constructor that accepts the following values as arguments and assigns them to...
Design and write a class named Employee that inherits the Person class from the previous exercise and holds the following additional data: ID number, department and job title. Once you have completed the Employee class, write a Python program that creates three Employee objects to hold the following data: Name ID Number Department Job Title Phone Susan Meyers 47899 Accounting Vice President 212-555-1212 Mark Jones 39119 IT Programmer 212-555-2468 Joy Rogers 81774 Operations Engineer 212-555-9753 The Python program should store...
c++ Part 1 Consider using the following Card class as a base class to implement a hierarchy of related classes: class Card { public: Card(); Card (string n) ; virtual bool is_expired() const; virtual void print () const; private: string name; Card:: Card() name = ""; Card: :Card (string n) { name = n; Card::is_expired() return false; } Write definitions for each of the following derived classes. Derived Class Data IDcard ID number CallingCard Card number, PIN Driverlicense Expiration date...
in C++: Create a class named Student that has three member variables: name - string that stores the name of the student numClasses - integer that tracks how many courses the student is currently enrolled in, this number must be between 1 and 100. classList - an array of strings of size 100 used to store the names of the classes that the student is enrolled in Write the appropriate constructor(s), mutator and accessor functions for the class along with...
Define a class named Employee . Derive this class from the class Person. An employee record inherits an employee's name from the class Person. In addition, an employee record contains an annual salary (represented by a single value of type double), a hire date that gives the year hired (as a single value of type int), an identification number of type int, and a department of type String. Give your class a reasonable complement of constructors, accessors, mutators, an equals...
1) Introduction to Objects (with Constructors and Properties) We need to answer the question which are below. and instruction are given down starting with part(b). Just we need to copy paste code file and follow the instruction and answer related to them. a) Enter the following program.Answer The questions below the codes, Notice that it consists of two classes that will go into the same project. Please put each class into its own code file (use Lab5_1 for the Project...
Write a Java class named Employee to meet the requirements described in the UML Class Diagram below: Note: Code added in the toString cell are not usually included in a regular UML class diagram. This was added so you can understand what I expect from you. If your code compiles cleanly, is defined correctly and functions exactly as required, the expected output of your program will solve the following problem: “An IT company with four departments and a staff strength...