Question
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
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
#include
#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
#include
#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
#include
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
#include
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
#include
#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!!! (:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started