c++ inheritance

User Generated

xbbexbbev

Programming

Description

Implementation
This section further describes each class method found within the UML diagram.


Class Employee· get/setName gets and sets the employee's private name variable. Be sure to filter out bad input, such as empty strings.· get/setEmployeeId gets and sets the employee's ID number. Be sure to filter out ID numbers that are less than or equal to zero.· set/isWorking sets and gets whether or not the employee is working. No filtering is required.· toString returns a tab-delimited string in the following format: "name \t id \t is working"
Class StudentEmployee· get/setPayRate gets and sets the employee's pay rate. Be sure to filter out negative values.· get/setHoursWorked gets and sets the hours worked for the current week. Be sure to filter out negative values.· getWeeklyPay computes the student's weekly pay. To calculate, multiply the number of hours worked times the pay rate.· set/isWorkStudy sets and gets whether the student is work study.· toString() returns a tab-delimited string in the following format: "name \t id \t is working \t hours worked \t is work study \t pay rate"
Testing Our Classes
Use your main function to test the StudentEmployee class. In main, prompt the user for a CSV (comma separated value) file to open. Then, using the provided StringSplitter class, split the CSV using the comma as a delimiter and use the data to create a new StudentEmployee. Finally, output all StudentEmployees onto the screen.

we have :

CVS.TXT

Stan Stanley

1.23E+08

TRUE

19

FALSE

10.95

Ralph Maccio

2.59E+08

TRUE

15

FALSE

9.55

Julie Andrews

1.12E+08

FALSE

0

FALSE

0

Janice Young

5.59E+08

TRUE

19

TRUE

11.75

StringSplitter.h

#ifndef STRINGSPLITTER_H
#define STRINGSPLITTER_H

#include <string>
#include <vector>

using namespace std;

class StringSplitter
{
public:

  //Accepts a string and a delimiter.  Will use items_found to return the number
  //of items found as well as an array of strings where each element is a piece of
  //the original string.
  static string * split(string text, string delimiter, int &items_found)
  {
    //vectors are dynamically expanding arrays
    vector<string> pieces;

    //find the first delimiter
    int location = text.find(delimiter);

    //we are starting at the beginning of our string
    int start = 0;

    //go until we have no more delimiters
    while(location != string::npos)
    {
      //add the current piece to our list of pieces
      string piece = text.substr(start, location - start);
      pieces.push_back(piece);

      //update our index markers for the next round
      start = location + 1;
      location = text.find(delimiter, start);
    }

    //at the end of our loop, we're going to have one trailing piece to take care of.
    //handle that now.
    string piece = text.substr(start, location - start);
    pieces.push_back(piece);

    //convert from vector into an array of strings
    int size = pieces.size();
    string *pieces_str = new string[size];
    for(int i = 0; i < size; i++)
    {
      pieces_str[i] = pieces.at(i);
    }
    items_found = size;
    return pieces_str;     
  }
};

#endif


User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer

Thank you for the opportunity to help you with your question!

in general, do not need to be licensed or pass any standardized (or governmentally regulated) certification tests in order to call themselves "programmers" or even "software engineers.

Please let me know if you need any clarification. I'm always happy to answer your questions.

Related Tags