Search for question
Question

-Follow the instructions as given -Copy the same function names with the same parameters -Add comment to explain the use of the function -Follow the UML exactly -Use same file names in the file/n Review the assignment due date Programming Assignment #8 (PA8) Overview In this assignment, we will take a look at inheritance relationships, pointers and file reading. <i class="fa-solid fa-triangle-exclamation" style="margin-right: 10px;"></i> <b style="display: inline; margin-bottom: 8px; font-size: 16px; ">Naming Conventions:</b> <p><ul> • While implementation details are still up to you, make sure you use the coding style discussed in class regarding functions, name, classes, and indentations unless a specific name is given to you throughout this assignment. • If a specific name for something like a variable, class, or function is given to you, you MUST use it exactly or the autograder won't be able to find it and the tests will fail. • This applies to function prototypes/signatures/definitions as well. The inputs and outputs of the functions you implement must also match the ones specified. • Points will not be given for tests that fail due to incorrect naming or signature mismatch. • Variables should be localized with the correct scope, datatype (based on the data needed to be stored), and their names must be pneumonic. I.e., avoid variables like a, b, i, j, k, x, y, z, etc. • Coding style will be reviewed and your assessment grade may be impacted due to that as described in our syllabus. • Remember that homework must be completed individually without help (human or AI). <i class="fa-solid fa-fire-flame-curved" style="margin-right: 10px;"></i> <b style="display: inline; margin-bottom: 8px; font-size: 16px;">Restrictions: </b> <p><ul> • Only the libraries discussed in class can be used in homework: • string • array • vector iostream • iomanip • fstream • sstream • exception • The using namespace statement such as using namespace std; is not allowed in this homework. Tasks & TODOS <i class="fa-solid fa-circle-info"></i> <b style="display: inline; margin-bottom: 8px; font-size: 16px; ">Note:</b> <p>There are no TODO comments for this assignment as you are creating your own files. You can use the TODOS from prior PAs as a rough guide to the pieces you need. You should also refer to your class notes and textbook for guidance as necessary.</p> Part 1: Person And College Person 1. In the src directory, create .cpp and .h files for the Person and College Person classes. the .h file must contain only the declaration (prototypes). - Your header file should start (other than comments) with the lines: - #ifndef <CLASS_NAME>_H #define <CLASS_NAME>_H - The very last line in the file should be: - #endif the .cpp file must contain the implementation of the class methods. - Don't forget everything in C++ is case- sensitive. This includes file names. 2. The Person class - Member Variables - name: a string that holds the person name - age: an int that holds the person age - Constructors - Person(): a default constructor that takes no parameters. - Person(string, int): a parameterized constructor that takes values for each member variable in the above order - Getters & Setters - Getters & Setters for each member variable [4 in total]. 3. The CollegePerson class: - This class is a public derived class of Person - Member Variables - university: a string that holds the College Person university - college: a string that holds the CollegePerson college, such as “Engineering" - id: an int that holds the CollegePerson ID - earned: a float that holds the total points earned by the CollegePerson - total: a float that holds the full scores of all exams the CollegePerson taken - grade: a float that holds the CollegePerson grade - gpa: a float that holds the CollegePerson gpa - letterGradea: astring that holds the CollegePerson letterGrade - Constructors - College Person(): initialize member variables to default values (0 or for numbers and strings respectively) - College Person(string, int, string, string, int): a parameterized constructor that takes name (string, age(int), university(string), college(string) and id(int) as parameters to create a CollegePerson object. - Getters & Setters - Getters & Setters for each member variable [16 in total]. 4. Below is the UML representation of the class Person and CollegePerson. 6699 %%{ init: { 'themeVariables': { 'fontFamily': 'monospace' } } }%% classDiagram Person < College Person class Person { } - - name age string int + Person() + Person(string, int) + getName() : string + getAge() : int + setName(string) : void + setAge (int) : void class College Person { university: string - college string id int earned float - total float - grade - gpa float float - letterGrade: string + CollegePerson() + College Person(string, int string, string, int) + getUniv() string + getCollege() : string + getID() : int + getEarned () : float } + getTotal() : float + getGrade() : float + getgpa() float + getLetterGrade() : string + setUniv(string) : void + setCollege(string) : void + setID (int) : void + setEarned (float) : void + setTotal(float) : void + setGrade(float) : void + setgpa (float) : void + setLetterGrade(string) : void Part 2: Global Functions 1. In the src directory, create functions.cpp and functions.h files - the .h file must contain only the declaration (prototypes). - the .cpp file must contain the implementation of the functions. You will utilize the Person and College Person classes that were defined in Part 1. - You will declare and implement 5 global functions. 2.A text file(data/data.txt) with the students' names and scores for various deliverables is provided. Each score represents the points earned for the particular deliverable. The total points possible are also entered in the file. - The format of the file will be as shown below (same as file data/data.txt). - Notice the field delimiter is the comma, the delimiter for the sub-records (for each student) is the newline, and the delimiter for the main records is a blank line. John Jones, 22, UCD, Engineering, 813 HW1,15/20 HW2, 22/25 // name, age, University, College, id // task name, earned points/ full points HW3,18/20 M1,47/50 P1,42/50 Sara Smith, 19, Metro State, Engineering, 805 HW1,14/20 HW2, 17/25 HW3,16/20 M1,42/50 P1,44/50 3.Functions in functions - void greeting() : - A greeting is displayed on the screen. The greeting info is "Press Enter to Continue” - The user is asked to press a key and enter to continue. - int recordCount(); - open the file(data/data.txt) and count the number of student records - Returns the number of student records in the file(data/data.txt). - The student records are separated by an empty line. - void getInput(vector<CollegePerson*>); -A vector of college records is created(You don't need to instantiate the CollegePerson in your code) - The data is read from the file(data/data.txt) and used to generate the CollegePerson records. - After that, the CollegePerson's name, age, University, College, id, earned points, and total points will be set. individual grades are not stored, just the running total of points earned and points total possible. - call recordCount() inside may be helpful - Hint: use stringstream, str(), clear() • void calc Grades (vector<CollegePerson*>); • The final Grade is calculated. ■ Formula: grade = (earned / total) * 100 ■ You must to use this formula provided. 。 The final GPA and letter grades are calculated. 。 The corresponding records in vecter was set correctly. • The GPA standard used is as shown below. grade lettergrade gpa 94 grade <= 100 A+ 4.5 89 grade <= 94 A 4.0 84 grade <= 89 B+ 3.5 79 grade <= 84 B 3.0 74 grade <= 79 C+ 2.5 69 grade <= 74 C 2.0 64 grade <= 69 D+ 1.5 60 grade <= 64 D 1.0 grade <= 60 F 0 • void display(vector<CollegePerson*>); 。 Output format is as shown below. ■ The display function should display records grouped by university name(only UCD and Metro State, so you can use if statements). • The left side of the each field is 15 characters. UCD Name Age ID Grade John Jones B+ 22 813 College Engineering 3.5 GPA Metro State Name Age ID College GPA Grade Sara Smith 19 805 Engineering 3 B Paul Davis 28 427 Management 0 F 4.Create a main.cpp file with an int main() and use it to test your code. Specifications • For part 2, the main.cpp should instantiate CollegePerson objects, declare a vector<CollegePerson*>, allocate College Person object according to records count and pushback pointers. (Remember to delete them.) • You can use the data/data.txt to test your functions (or other datas. But please don't overwrite this file). <i class="fa-solid fa-exclamation" style="margin-right: 10px;"></i> <b style="display: inline; margin-bottom: 8px%3B font-size: 16px; ">Important!</b> <p>Failure to complete this step may result in a loss of points!</p> Testing Your code will run against unit tests on an Autograder. The Autograder runs on Ubuntu Linux so the unit tests are configured for that OS only. You can run the tests in a Codespace (which uses Ubuntu as well) or on your own Ubuntu environment (if you have one) using the provided g++ instructions. Remember tests must pass on the Autograder to receive points. Compiling It is expected that you are able to compile and run your own code without relying solely on other tools. This includes the VS Code Debugger's "Play/Run” Button. You should not be using that at all for this assignment. Here is the general format for g++ (you leave out the [ ] characters when actually writing the commands ): g++ [relevant setting and flags. These usually start with a -] [list of The g++ build command does use a couple extra settings when compiling with the unit tests. The additional options and what they signify are explained here: • [.cpp files, .o files, and a files]: Now, list off any .cpp source files, .o object files, and .a static library files that need to be included in the build. For all of these, you must include the relative file path for any files that aren't in working directory. your current 。 You will first list off any .cpp files needed by your program to run. In general, if your code uses an #include "*.h" statement, you will put the corresponding .cpp file here. 。 Then, add the object file for the test(s) you wish to run. Remember you must also include the relative file path if you are in a different working directory from the .o file (for example, ../tests/ if you are in the src folder or just tests/ if you at the root of the repo). 。 Lastly, include the file gtest_main.a. This file contains the main program needed to launch the unit tests against your code. ▪ Remember: A build must include exactly one (1) main function so you can't include your own main when running the unit tests. ⚫ -lpthread: Links the pthread library to the resulting executable. In essence, it ensures that threading functions are available in the resulting binary. The unit tests use multithreading which is why we are including it. ⚫ -o: This option lets you specify the name of the file you want g++ to output the executable code. If a file with that name already exists, it will be overwritten. The default output file is a. out if you don't include this option. Here is an example of a build command that could be used for this assignment. In this example, the working directory is repository root or top level of the repository: g++ -std=c++14 src/Person.cpp src/College Person.cpp src/functions.cpp tes