Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ include the main file, student.cpp file, and student.h file please This lab has been designed for you to practice the implementation and testing of

image text in transcribed

image text in transcribed

image text in transcribed

C++ include the main file, student.cpp file, and student.h file please

This lab has been designed for you to practice the implementation and testing of member functions of a Student class. The 04_student project contains the following Student class in the "Student.h" file. class student private: string name_; string pronouns_; unsigned labs_[10]; public: Student(); Student(const string\& name, const string\& pronouns); //accessor string to_string() const; //mutator void update_lab(unsigned pos, unsigned grade ); void update_labs(const string\& grades); void update_labs(const unsigned grades []); \}; Here are more details about the private data members: - name_ is to store the name for a student. - pronouns_is to store the gender pronouns for the student in the "subjective/objective/possessive" pronouns form. For example, "she/her/her", "he/him/his", "they/them/their"... - labs_ is to store the lab grades for a student. You are asked to implement the member functions of the Student class in the "Student.cpp" file and test them in the "main.cpp" file. Here are more details about the expected behavior of the public member functions: Student: :Student () ; The default constructor is to set the name_and pronouns_ of a new Student object to "Unkown" and "they/them/their", respectively. In addition, the constructor shall initialize the lab grades to 0 for all ten labs. Student: :Student (const string\& name, const string\& pronouns); This constructor takes a string parameter name that represents a student name and a string parameter pronouns that represents the student's preferred gender pronouns in the "subjective/objective/possessive" format. The constructor is to create a new Student object using the name and pronouns provided. In addition, the constructor shall initialize the lab grades to 0 for all ten labs. string student: :to_string() const; This accessor function is to return a string that contains a summary of the invoking Student object. For example, given the following code segment: Student a; cout a.to_string ( ) end ; Your program shall generate the following output. Note the returned string from the to string function includes the following about the invoking Student object: name, subjective and possessive pronoun, the ten lab grades in two rows, and total earned points for the labs. void Student: : update_lab (unsigned pos, unsigned grade); This mutator function is to update a specific lab's grade for the invoking Student object. It takes two unsigned parameters pos and grade that represent the index of the specific lab to update and the new grade for that lab, respectively. For example, given the following code segment: Student a; a. update_lab( 2,10); cout a.to_string () end ; Your program shall generate the following output: If an invalid pos and/or grade are provided for the function, no change shall be made to the labs_array. Instead, the function shall display a message explaining why the update is not successful. void Student: : update_labs (const string \& grades); This mutator function is to update all the elements of the labs_ array for the invoking Student object. It takes a string grades that contains ten integers separated by commas. Each integer represents a lab grade from 0 to 10 . The function parses the string grades using string stream and assigns the first integer to the first lab grade, the second integer to the second lab grade and so on. For example, given the following call to update_labs and to_string: Student a; a. update_labs( "10,9, 9,7,6,5,4,3,2,1"); cout a.to_string () end ; Your program shall generate the following output: The student's name is Unknown; their lab grades are: 10594937261 overall, they earned 56 out of 100 points. void Student: : update_labs (const unsigned grades []); This mutator function is to update all the elements of the labs_array for the invoking Student object. It takes an array of unsigned integers grades as a parameter and copies the first ten elements of grades to the labs_array. In the "main.cpp", create at least two Students objects using different constructors, then test the different mutator and accessor methods. You are encouraged to call the to_string method after every function call to help test these functions

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database 19c DBA By Examples Installation And Administration

Authors: Ravinder Gupta

1st Edition

B09FC7TQJ6, 979-8469226970

More Books

Students also viewed these Databases questions

Question

How would you describe your typical day at work?

Answered: 1 week ago