1. quarterback ratings in football, there is a statistic for

For this assignment, you will be creating classes with data members and methods.


The classes for each problem should be defined in a separate .h file with the implementation of methods in a separate .cpp file.



NOTE: Before submission, check to make sure your assignment does not have any cout statements


For this assignment, you will create a new project within CodeBlocks. You can name the project any name you like, but each problem has a specific file name to be used for the .h and .cpp files associated with the classes. See the individual problems for those names. Your project will contain 5 files total: main.cpp file, 2 .cpp files(one for each class), and 2 .h files(one for each class).


Once you have your code running on your virtual machine (VM), you must submit it to the autograder by zipping only the .h and .cpp files(not the main.cpp) for the


                                created classes into a single file to be submitted. Youmust also submit your code(.zip) to Moodle to get full credit for the assignment.



Your upload file needs to be named Lastname_Firstname_Assignment7.zip for the grading script to run.Your classes will be included and accessed in the testing application’s main function.


If you do not get your assignment to run on COG before the assignment deadline, you will have the option of scheduling an interview grade with your TA to get a grade for the assignment. We’ll talk more about scheduling the interview in lecture and recitation. Even if you do get the assignment to run on COG, you can schedule the interview if you just want to talk about the assignment and get feedback on your




implementation. However, you must submit your code to Moodle to get credit for your program.


Submitting Your Code to Moodle:


You must submit your code to Moodle to get full credit for the assignment, even if the computer science autograder gives you a perfect score.


Please also include comments in your code submission to describe what your code is doing. Comments should also include your name, recitation TA, and the assignment and problem number. TAs will be checking that you code has comments and adequate indentation and variable names..




These problems will require you to create a class description in a .h file and place all the code for implementing the classes into a .cpp file. You will need to write a main.cpp to hold your main() function that will test your classes. You will #include “yourfile.h” at the beginning of your main.cpp to define your class for use inmain() function.


REMEMBER: the code submitted to Moodle will be reviewed and up to a 20 point reduction will be assessed for poor coding style (lacking proper indentation, descriptive variable names, or required comments)


1. Quarterback Ratings


In football, there is a statistic for quarterbacks called the passer rating. There are five input parameters to the calculation: pass completions, pass attempts, total passing yards, touchdowns, and interceptions. The calculations required have been listed below.


You will create a class where the class description is placed in a file named

                         Quarterback.h and a file namedQuarterback.cpp will contain theimplementation of the methods for that class. COG will use these files to test your implementation of the class.


                    Create a class called Quarterback that has the following private data members (all integer values except the string for name):


i.         i.                            Quarterback Name


i.          ii.                            Pass completions


i.          iii.                           Pass attempts


i.          iv.                           Total passing yards


i.         v.                           Touchdowns


i.          vi.                           Interceptions




class Quarterback




// data members private:

       //                           …


       //                           methods




            Quarterback(); Quarterback(string data);


       //                           access methods


string getName();


void setName(string new_name);


int getComp();


void setComp(int value);


int getAtt();


void setAtt(int value);


int getYards();


void setYards(int value);


int getTD();


void setTD(int value);


int getPick();


void setPick(int value);


       //                           add the required functions here


                                       //     helper methods – only used by class methods private:


            float calcC(); float calcY(); float calcT(); float calcI();




The class should have two constructors, one that takes no parameters, and one that takes a single string parameter that contains the values for each of the members listed above (in that same order) separated by a comma.



Data Format Example:


D. McNabb, 180, 316, 2647, 18, 6


The class must have access methods for both getting and setting the values of private members. There should also be a method for each variable to increment the values, which could be used in a simulated game. These methods do not return a value, only update the object’s data.


PassCompleted(int yards) — update comp, attempts, yards.


PassAttempted() — updates attempts.


Touchdown(int yards) — update comp, att, yards, touchdowns.


Interception() — updates attempts, interceptions



The class must have a method called PasserRating() that performs the following calculations and returns a float value:


C = (completions per attempt – 0.30) * 5


Y = (yards per attempt – 3) * 0.25


T = touchdowns per attempt * 20


I = 2.375 – (Intercepts per attempt * 25)


If C, Y, T, or I is less than 0, then set it to 0


If C, Y, T, or I is greater than 2.375, then set it to 2.375


PasserRating = (C+Y+T+I)/6*100


The class must have a method called Evaluation() which will return a subjective evaluation string based on the passer rating. A rating is “poor” if it is 85 or below, “mediocre” if above 85, “good” if above 90, and “great” if above 95.


To test your program, look up actual data onwww.nfl.comor  http://www.pro-football-reference.com/years/2015/passing.htmoruse the following information from 2015:


Philip Rivers, 437, 661, 4792, 29, 13


Drew Brees, 428, 627, 4870, 32, 11


Tom Brady, 402, 624, 4770, 36, 7



COG will test your code by using both the string constructor and the default constructor in a simulated game (calling the incremental functions, then asking for a rating calculation).



2. Cycling: Power and Energy


This is a continuation of Assignment #3. See that assignment for all the equations. If you had the correct calculations in your solution for that assignment, you should be able to reuse the code here.


You will create a class where the class descriptions are placed in a file named BikeRacer.h and a file namedBikeRacer.cpp will contain theimplementation of the methods for those classes. COG will use these files to test your implementation of the classes.


Create a class called Racer. The class Racer will contain privatefloating point variables for data listed below. All these data members should be private, with publicaccess methods to get and set the values. Racer constructor will need to initialize all the member variables.


Mass of the bike in kg


Coefficient related to the resistance of the bike on the road


Mass of the rider in kg


Velocity in m/s


Coefficient related to rider position(K)


Coefficient of drafting


//Access methods Racer::setBikeMass(…) Racer::getBikeMass()






Racer::setRiderMass (…)








Racer::setK (…)




Racer::setVelocity (…)





The power output for a cyclist (measured in Watts) can be calculated from the power needed to overcome air resistance and the power needed to



overcome rolling resistance. Write a method Power() for Racer to calculate the floating point value for power required per second based on current racer and racer’s bike settings.


Write a method to calculate the total power required to travel a given distance in kilometers. TotalEnergy(float distance) will return the floating point value for total energy as specified in the previous assignment’s write up.


Use the following values to test your classes:




M =15


Cr = 0.001




M = 63 k = 0.18 v = 10.8

CFdraft = 0.70


you should get 166.9 W
















Posted in Uncategorized