Question

Greetings, everybody I already started working in this program. I just need someone to help me...

Greetings, everybody

I already started working in this program. I just need someone to help me complete this part of the assignment (my program has 4 parts of code: main.cpp; Student.cpp; Student.h; StudentGrades.cpp; StudentGrades.h)

Just Modify only the StudentGrades.h and StudentGrades.cpp files to correct all defect
you will need to provide implementation for the copy constructor, assignment operator, and destructor for the StudentGrades class.

Here are my files:

(1) Main.cpp

#include <iostream>

#include <string>

#include "StudentGrades.h"

using namespace std;

int main()

{

                StudentGrades a;

                StudentGrades b; // object b will be used for the tests that require b = a;

                Student s;

                // Test Case 1

                s = a.getStudentWithHighestGrade();

                // get the student with highest grade at initialization

                std::cout << "Student " << s.getName() << " has highest grade of " << s.getGrade() << std::endl;

                if ((s.getName().compare("No Entry") == 0) && (s.getGrade() == 0))

                                // if the test case is meet then Pass

                                std::cout << "Test Case 1 Passes" << std::endl;

                else // else test case fails

                                std::cout << "Test Case 1 Fails" << std::endl;

                // Test Case 2

               

}

(2) Student.cpp

#include <iostream>

#include <string>

#include "Student.h"

using namespace std;

Student::Student()

{

}

Student::Student(std::string n, int g) : name(n), grade(g)

{}

Student::~Student()

{}

void Student::setName(std::string name)

{

                this->name = name;

}

void Student::setGrade(int g)

{

                grade = g;

}

std::string Student::getName() const

{

                return name;

}

int Student::getGrade() const

{

                return grade;

}

(3) Student.h

#include <iostream>

#include <string>

using namespace std;

#ifndef STUDENT_H

#define STUDENT_H

class Student

{

public:

Student(); // default constructor

Student(std::string n, int g); // constructor

~Student(); // destructor

void setName(std::string name); // mutator function

void setGrade(int g); // mutator function

std::string getName() const; // accessor function

int getGrade() const; // accessor function

private:

std::string name;// holds the student name

int grade;// holds the student grage

};

#endif

(4) StudentGrades.cpp (Modify this part for implementation)

#include <iostream>

#include <string>

using namespace std;

#ifndef STUDENT_H

#define STUDENT_H

class Student

{

public:

Student(); // default constructor

Student(std::string n, int g); // constructor

~Student(); // destructor

void setName(std::string name); // mutator function

void setGrade(int g); // mutator function

std::string getName() const; // accessor function

int getGrade() const; // accessor function

private:

std::string name;// holds the student name

int grade;// holds the student grage

};

#endif

(5) StudentGrades.h  (Modify this part for implementation)

#include <iostream>

#include <string>

#include "Student.h"

#ifndef STUDENTGRADES_H

#define STUDENTGRADES_H

class StudentGrades

{

public:

                StudentGrades(); // default constructor

                ~StudentGrades(); // destructor

                Student getStudentWithHighestGrade() const; // accessor function

                void addStudentRecord(std::string name, int grade);

                void resetList();

private:

                const static int MAX_STUDENTS = 5;

                int numberOfStudents;

                Student *students;

};

#endif

Thank you!!! (:

0 0
Add a comment Improve this question Transcribed image text
Answer #1

please give thumbs up, thanks

ADD these in .h file:

StudentGrades& operator = ( const StudentGrades &S);//assignment

StudentGrades(StudentGrades &S);//copy Construction

~StudentGrades();// destructor

ADD these in .cpp file:

StudentGrades::StudentGrades():numberOfStudents(0)

{

students = new Student[MAX_STUDENTS];

}

StudentGrades::StudentGrades( StudentGrades &S):numberOfStudents(S.numberOfStudents), students(S.students)

{

}

StudentGrades & StudentGrades ::operator = ( const StudentGrades &S)

{

this->numberOfStudents=S.numberOfStudents;

this->students= new Student[MAX_STUDENTS];

for(int i=0; i<S.numberOfStudents; i++)

{

this->students[i]=S.students[i];

}

return *this;

}

StudentGrades::~StudentGrades()

{

delete[] students;

}

Add a comment
Know the answer?
Add Answer to:
Greetings, everybody I already started working in this program. I just need someone to help me...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • #ifndef PROCESSREQUESTRECORD_CLASS #define PROCESSREQUESTRECORD_CLASS #include <iostream> #include <string> using namespace std; class procReqRec { public: //...

    #ifndef PROCESSREQUESTRECORD_CLASS #define PROCESSREQUESTRECORD_CLASS #include <iostream> #include <string> using namespace std; class procReqRec { public: // default constructor procReqRec() {} // constructor procReqRec(const string& nm, int p); // access functions int getPriority(); string getName(); // update functions void setPriority(int p); void setName(const string& nm); // for maintenance of a minimum priority queue friend bool operator< (const procReqRec& left, const procReqRec& right); // output a process request record in the format // name: priority friend ostream& operator<< (ostream& ostr, const procReqRec&...

  • This is a simple C++ class using inheritance, I have trouble getting the program to work....

    This is a simple C++ class using inheritance, I have trouble getting the program to work. I would also like to add ENUM function to the class TeachingAssistant(Derived class) which is a subclass of Student(Derived Class) which is also a subclass of CourseMember(Base Class). The TeachingAssistant class uses an enum (a user-defined data type) to keep track of the specific role the TA has: enum ta_role {LAB_ASSISTANT, LECTURE_ASSISTANT, BOTH}; You may assume for initialization purposes that the default role is...

  • Complete Course.cpp by implementing the PrintRoster() function, which outputs a list of all students enrolled in a course and also the total number of students in the course.

    Complete Course.cpp by implementing the PrintRoster() function, which outputs a list of all students enrolled in a course and also the total number of students in the course.Given files: main.cpp - contains the main function for testing the program.Course.cpp - represents a course, which contains a vector of Student objects as a course roster. (Type your code in here)Course.h - header file for the Course class.Student.cpp - represents a classroom student, which has three data members: first name, last name, and...

  • C++ Lab 9A Inheritance Employee Class Create a project C2010Lab9a; add a source file Lab9a.cpp to...

    C++ Lab 9A Inheritance Employee Class Create a project C2010Lab9a; add a source file Lab9a.cpp to the project. Copy and paste the code is listed below: Design a class named Employee. The class should keep the following information in member variables: Employee name Employee number Hire date // Specification file for the Employee class #ifndef EMPLOYEE_H #define EMPLOYEE_H #include <string> using namespace std; class Employee { private:        // Declare the Employee name string variable here. // Declare the Employee...

  • Write a C++ program that includes the following: Define the class Student in the header file Stu...

    Write a C++ program that includes the following: Define the class Student in the header file Student.h. #ifndef STUDENT_H #define STUDENT_H #include <string> #include <iostream> using namespace std; class Student { public: // Default constructor Student() { } // Creates a student with the specified id and name. Student(int id, const string& name) { } // Returns the student name. string get_name() const { } // Returns the student id. int get_id () const { } // Sets the student...

  • C++ programming question, please help! Thank you so much in advance!!! In this exercise, you will...

    C++ programming question, please help! Thank you so much in advance!!! In this exercise, you will work with 2 classes to be used in a RPG videogame. The first class is the class Character. The Character class has two string type properties: name and race. The Character class also has the following methods: a constructor Character(string Name, string Race), that will set the values for the name and the race variables set/get functions for the two attributes a function print(),...

  • I need help with this assignment, can someone HELP ? This is the assignment: Online shopping...

    I need help with this assignment, can someone HELP ? This is the assignment: Online shopping cart (continued) (C++) This program extends the earlier "Online shopping cart" program. (Consider first saving your earlier program). (1) Extend the ItemToPurchase class per the following specifications: Parameterized constructor to assign item name, item description, item price, and item quantity (default values of 0). (1 pt) Public member functions SetDescription() mutator & GetDescription() accessor (2 pts) PrintItemCost() - Outputs the item name followed by...

  • Hi there, I am working on a binary search tree code in c++. The program must...

    Hi there, I am working on a binary search tree code in c++. The program must store and update students' academic records, each node includes the student name, credits attempted, credits earned and GPA. I have made some progress with the code and written most of the functions in the .cpp file (already did the .h file) but i am struggling with what to put in the main and how to put an update part in the insert function. I...

  • My main() file does not call to the class created in a .hpp file. It comes...

    My main() file does not call to the class created in a .hpp file. It comes out with the error "undefined reference to "___" const. I want to solve this by only changing the main() .cpp file, not the .hpp file. .cpp file .hpp file Thank you! include <iostream> include <string> tinclude "CourseMember.hpp using namespace std int main0 CourseMember CourseMember(90, "Jeff", "Goldblum"): // initializing the constructor cout<< "Member ID is <<CourseMember.getID) << endl; 1/ calling getID) accessor cout <<"First Name...

  • CODES: main.cpp #include <iostream> #include <string> #include "ShoppingCart.h" using namespace std; char PrintMenu() { char answer;...

    CODES: main.cpp #include <iostream> #include <string> #include "ShoppingCart.h" using namespace std; char PrintMenu() { char answer; cout << "MENU" << endl; cout << "a - Add item to cart" << endl; cout << "d - Remove item from cart" << endl; cout << "c - Change item quantity" << endl; cout << "i - Output items' descriptions" << endl; cout << "o - Output shopping cart" << endl; cout << "q - Quit" << endl << endl; while (true) {...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT