Question

In: Computer Science

Trying to create a Class of Employees that holds every Employee created from a class called...

Trying to create a Class of Employees that holds every Employee created from a class called Employee in c++

Solutions

Expert Solution

#include <iostream>
#include <string>

using namespace std;

class Employee {
private:
    string name;
    int idNumber;
    string department;
    string position;
public:
    Employee(string name, int idNumber, string department, string position) :
            name(name), idNumber(idNumber), department(department), position(position) {}
            
    Employee(string name, int idNumber) : name(name), idNumber(idNumber), department(""), position("") {}
    
    Employee() : name(""), idNumber(0), department(""), position("") {}

    string getName() {
        return name;
    }

    void setName(string name) {
        this->name = name;
    }

    int getIdNumber() {
        return idNumber;
    }

    void setIdNumber(int idNumber) {
        this->idNumber = idNumber;
    }

    string getDepartment() {
        return department;
    }

    void setDepartment(string department) {
        this->department = department;
    }

    string getPosition() {
        return position;
    }

    void setPosition(string position) {
        this->position = position;
    }
};

int main() {
    Employee employee1;
    employee1.setName("Cristiano ronaldo");
    employee1.setIdNumber(7);
    employee1.setDepartment("IT");
    employee1.setPosition("Engineer");

    cout << "Name: " << employee1.getName() << "\n" << "ID Number: " << employee1.getIdNumber() << "\nDepartment: " << employee1.getDepartment() << "\nPosition" << employee1.getPosition() << endl << endl;
    return 0;
}

Related Solutions

Java Coding Part A Create a class Employee. Employees have a name.   Also give Employee a...
Java Coding Part A Create a class Employee. Employees have a name.   Also give Employee a method paycheck() which returns a double. For basic employees, paycheck is always 0 (they just get health insurance). Give the class a parameterized constructor that takes the name; Add a method reportDeposit. This method prints a report for the employee with the original amount of the paycheck, the amount taken out for taxes (we will do a flat 17%), and the final amount (for...
In Java Create a class called "TestZoo" that holds your main method. Write the code in...
In Java Create a class called "TestZoo" that holds your main method. Write the code in main to create a number of instances of the objects. Create a number of animals and assign a cage and a diet to each. Use a string to specify the diet. Create a zoo object and populate it with your animals. Declare the Animal object in zoo as Animal[] animal = new Animal[3] and add the animals into this array. Note that this zoo...
Create a C# Application. Create a class object called “Employee” which includes the following private variables:...
Create a C# Application. Create a class object called “Employee” which includes the following private variables: firstN lastN idNum wage: holds how much the person makes per hour weekHrsWkd: holds how many total hours the person worked each week regHrsAmt: initialize to a fixed amount of 40 using constructor. regPay otPay After going over the regular hours, the employee gets 1.5x the wage for each additional hour worked. Methods: constructor properties CalcPay(): Calculate the regular pay and overtime pay. Create...
Create a class called employee which has the following instance variables: Employee ID number Salary Years...
Create a class called employee which has the following instance variables: Employee ID number Salary Years at the company Your class should have the following methods: New employee which reads in an employee’s ID number, salary and years of service Anniversary which will up the years of service by 1 You got a raise which will read in how much the raise was (a percent) and then calculate the new salary You get a bonus which gives a yearly bonus...
in Java, Create a class called EMPLOYEE that includes three instance variables – a first name...
in Java, Create a class called EMPLOYEE that includes three instance variables – a first name (type String), a last name (type String) and a monthly salary (double). Provide a constructor that initializes the three instance variables. Provide a set and a get method for each instance variable. If the monthly salary is not positive, do not set its value. Write a test app names EmployeeTest that demonstrates class EMLOYEE’s capabilities. Create two EMPLOYEE objects and display each object’s yearly...
with PHP Create a class called Employee that includes three instance variables—a first name (type String),...
with PHP Create a class called Employee that includes three instance variables—a first name (type String), a last name (type String) and a monthly salary int). Provide a constructor that initializes the three instance data member. Provide a set and a get method for each instance variable. If the monthly salary is not positive, do not set its 0. Write a test app named EmployeeTest that demonstrates class Employee’s capabilities. Create two Employee objects and display each object’s yearly salary....
1. create a class called ArrayStack that is a generic class. Create a main program to...
1. create a class called ArrayStack that is a generic class. Create a main program to read in one input file and print out the file in reverse order by pushing each item on the stack and popping each item off to print it. The two input files are: tinyTale.txt and numbers.txt. Rules: You cannot inherit the StackofStrings class. 2. Using your new ArrayStack, create a new class called RArrayStack. To do this, you need a) remove the capacity parameter...
1. create a class called ArrayStack that is a generic class. Create a main program to...
1. create a class called ArrayStack that is a generic class. Create a main program to read in one input file and print out the file in reverse order by pushing each item on the stack and popping each item off to print it. The two input files are: tinyTale.txt and numbers.txt. Rules: You cannot inherit the StackofStrings class. 2. Using your new ArrayStack, create a new class called RArrayStack. To do this, you need a) remove the capacity parameter...
In R-Syntax, create a vector of 100 employees ("Employee 1", "Employee 2", ... "Employee 100") [Hint:...
In R-Syntax, create a vector of 100 employees ("Employee 1", "Employee 2", ... "Employee 100") [Hint: use the `paste()` function and vector recycling to add a number to the word "Employee"] then create a vector of 100 random salaries for the year 2017 [Use the `runif()` function to pick random numbers between 40000 and 50000] and finally create a vector of 100 salary adjustments between -5000 and 10000 [use runif() to pick 100 random #'s in that range]
class Company uses an ArrayList of class Employee to manage its employees. Your job is to...
class Company uses an ArrayList of class Employee to manage its employees. Your job is to create two classes , Company and Employee, with appropriate instance fields, constructors, and methods as been described in the set of questions that follows . A sample use case of the classes is shown below: public class CompanyTester{ public static void main(String[] args){ Company myCompany = new Company(); myCompany.add( new Employee("james","gasling")); myCompany.add( new Employee("bill","gate")); myCompany.add( new Employee("dennis","ritchie")); System.out.println(myCompany); } } The sample output of...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT