Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // SOURCE
- #include "student.h"
- #include <iostream>
- using namespace std;
- Student::Student() { // Empty constructor to set desired default values
- this->studentId = "";
- this->firstName = "";
- this->emailAddress = "";
- this->degreeProgram = "";
- this->age = 0;
- for (int i = 0; i < 3; i++) {
- this->daysToComplete[i] = 0;
- }
- // Constructor
- Student::Student(
- std::string studentIDParam,
- string firstName,
- string lastName,
- string emailAddress,
- int age,
- int daysToComplete[]
- ) {
- studentID = studentIDParam; // Eschew `this` with unique identifier
- this->firstName = firstName;
- this->lastName = lastName;
- this->emailAddress = emailAddress;
- this->age = age;
- this->daysToComplete[0] = daysToComplete[0]; // Alternative to for loop
- this->daysToComplete[1] = daysToComplete[1];
- this->daysToComplete[2] = daysToComplete[2];
- }
- //Destructor
- Student::~Student() { // Destructor does nothing bc Student object does not allocate anything dynamically
- cout << "Goodbye student" << endl;
- }
- /* -------------------------------------------------------------------- */
- //Getters
- string Student::getStudentId() {
- return studentId;
- }
- string Student::getFirstName() {
- return this->firstName;
- }
- string Student::getLastName() {
- return this->lastName;
- }
- string Student::getEmailAddress() {
- return this->emailAddress;
- }
- string Student::getDegreeProgram() {
- return this->degreeProgram;
- }
- int Student::getAge() {
- return this->age;
- }
- int * Student::getDaysToComplete() {
- return this->daysToComplete;
- }
- /* -------------------------------------------------------------------- */
- //Setters
- void Student::setStudentId(string idParam) {
- studentId = idParam; // Circumvent using `this` using unique identifiers
- }
- void Student::setFirstName(string firstName) {
- this->firstName = firstName;
- }
- void Student::setLastName(string lastName) {
- this->lastName = lastName;
- }
- void Student::setEmailAddress(string emailAddress) {
- this->emailAddress = emailAddress;
- }
- void Student::setAge(int age) {
- this->age = age;
- }
- /* -------------------------------------------------------------------- */
- void Student::setDaysToComplete(int daysToComplete[]) {
- for (int i = 0; i < 3; i++) {
- this->daysToComplete[i] = daysToComplete[i];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement