SHARE
TWEET

Untitled

pipingpiccolo Sep 19th, 2019 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // SOURCE
  2.  
  3. #include "student.h"
  4. #include <iostream>
  5. using namespace std;
  6.  
  7. Student::Student() { // Empty constructor to set desired default values
  8.     this->studentId = "";
  9.     this->firstName = "";
  10.     this->emailAddress = "";
  11.     this->degreeProgram = "";
  12.     this->age = 0;
  13.  
  14.     for (int i = 0; i < 3; i++) {
  15.         this->daysToComplete[i] = 0;
  16. }
  17.  
  18. // Constructor
  19. Student::Student(
  20.     std::string studentIDParam,
  21.     string firstName,
  22.     string lastName,
  23.     string emailAddress,
  24.     int age,
  25.     int daysToComplete[]
  26. ) {
  27.     studentID = studentIDParam; // Eschew `this` with unique identifier
  28.     this->firstName = firstName;
  29.     this->lastName = lastName;
  30.     this->emailAddress = emailAddress;
  31.     this->age = age;
  32.  
  33.     this->daysToComplete[0] = daysToComplete[0]; // Alternative to for loop
  34.     this->daysToComplete[1] = daysToComplete[1];
  35.     this->daysToComplete[2] = daysToComplete[2];
  36. }
  37.  
  38. //Destructor
  39. Student::~Student() { // Destructor does nothing bc Student object does not allocate anything dynamically
  40.     cout << "Goodbye student" << endl;
  41. }
  42.  
  43. /* -------------------------------------------------------------------- */
  44.  
  45. //Getters
  46. string Student::getStudentId() {
  47.     return studentId;
  48. }
  49.  
  50. string Student::getFirstName() {
  51.     return this->firstName;
  52. }
  53.  
  54. string Student::getLastName() {
  55.     return this->lastName;
  56. }
  57.  
  58. string Student::getEmailAddress() {
  59.     return this->emailAddress;
  60. }
  61.  
  62. string Student::getDegreeProgram() {
  63.     return this->degreeProgram;
  64. }
  65.  
  66. int Student::getAge() {
  67.     return this->age;
  68. }
  69.  
  70. int * Student::getDaysToComplete() {
  71.     return this->daysToComplete;
  72. }
  73.  
  74. /* -------------------------------------------------------------------- */
  75.  
  76. //Setters
  77.  
  78. void Student::setStudentId(string idParam) {
  79.     studentId = idParam; // Circumvent using `this` using unique identifiers
  80.  
  81. }
  82.  
  83. void Student::setFirstName(string firstName) {
  84.     this->firstName = firstName;
  85. }
  86.  
  87. void Student::setLastName(string lastName) {
  88.     this->lastName = lastName;
  89. }
  90.  
  91. void Student::setEmailAddress(string emailAddress) {
  92.     this->emailAddress = emailAddress;
  93. }
  94.  
  95. void Student::setAge(int age) {
  96.     this->age = age;
  97. }
  98.  
  99. /* -------------------------------------------------------------------- */
  100.  
  101. void Student::setDaysToComplete(int daysToComplete[]) {
  102.     for (int i = 0; i < 3; i++) {
  103.         this->daysToComplete[i] = daysToComplete[i];
  104.     }
  105. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top