Develop and apply an appropriate and useful inheritance hierarchy.

Develop and apply an appropriate and useful inheritance hierarchy.

Develop and apply an appropriate and useful inheritance hierarchy.

[contact-form][contact-field label=”Name” type=”name” required=”true” /][contact-field label=”Email” type=”email” required=”true” /][contact-field label=”Website” type=”url” /][contact-field label=”Message” type=”textarea” /][/contact-form]

Use multiple cpp and header files effectively to develop modular code. Background Assume that all baseball players, regardless of their position, have these two important statistics: • rbi – runs batted in, a whole number (so you must data type int) • batting average – real number percentage of hits per at-bat (a real number, so you must use data type double) Pitchers are baseball players with an additional statistic, era (earned run average), a real number for earned runs per nine innings pitched (so you must use data type double). Developing the Class Hierarchy A logical class hierarchy for these two types of objects would use a Player class as a parent (base) class for a derived (child) Pitcher class. The Pitcher class would include all the members of the Player class and have an additional (private) era data member, and, of course, appropriate (public) accessor, mutator and constructor methods. This relationship is sometimes called a tree, but is also called a hierarchy, more particularly in this case, a class hierarchy. Note that the arrow points from derived (child) class to parent (base) class, which indicates the search path for executing member methods; if the method is not found in the Pitcher class, the compiler looks back to the parent class, Player, to find it. File Organization (Class Header and Implementation Files, etc.) Each class (in this case Player and Pitcher) will have its own header (.h) and implementation (.cpp) file, and, of course, there needs to be an executable file that actually uses the class (an application .cpp file with a main function). As with the classes previously developed in the course, the application will be a “driver” program that executes each member function at least once with an arbitrary, but specific test case data set. Requirements Use the given Player class as a base class for Pitcher and add to the BaseballPlayerDriver file code to test the class with the data specified below. Player class requirements: 1. Create with separate header (Player.h) and implementation (Player.cpp) files. 2. Two private data members, rbi and battingAverage. 3. A parameterized constructor that receives and sets the initial values for both rbi and battingAverage. 4. Two accessor (get) methods that return the values of the data members: getRbi and getBattingAverage. 5. Two mutator methods: 5.1. setRbi that receives a whole number and writes it to the rbi data member. 5.2. setBattingAverage that receives a real number and writes it to the battingAverage data member. 6. showAll accessor method that displays the values of both data members as shown here for an arbitrary test case for a player who has 10 rbi and batting average 0.1234: rbi = 10 batting average = 123 Note that the battingAverage variable will be a floating point number (double), but it must be rounded and display as a digit integer. Pitcher class requirements: 1. Pitcher class must be derived from Player class. 2. Create with separate header (Pitcher.h) and implementation (Pitcher.cpp) files. 3. One private data member, era. 4. A parameterized constructor that receives and sets the initial values for all three data members, rbi, battingAverage and era. 5. getEra accessor method that returns the value of era. 6. setEra mutator method that receives a real number and writes it to the era data member. 7. showAll function to over-ride the base class’s showAll function and do the following: call the base class’s showAll function to display the inherited data members’ values and, in addition, output the additional value, the pitcher’s era, as shown for an arbitrary test case for a pitcher who has 10 rbi, batting average 0.1234 and era of 3.456: rbi = 10 batting average = 123 era = 3.46 Note that the era variable will be a floating point number (double), but it must be rounded and display to decimal places. BaseballPlayerDriver class requirements: 1. Tell the user you’re creating a Pitcher with 10 rbi, batting average 0.1234 and era 3.456. 2. Use the parameterized constructor to create to instantiate a Pitcher variable, p1 with initial values 10 rbi, batting average 0.1234 and era 3.456. 3. Tell the user you’re using the get methods to display the values of the data members. 4. Use cout and the three get methods to display the values. 5. Tell the user you’re using the showAll method to display the values of the data members. 6. Call the showAll method. 7. Tell the user you’re using setRbi to change it to 9. 8. Use setRbi to change it to 9. 9. Use showAll to display the data values. 10. Tell the user you’re using setBattingAverage to change it to 0.2345. 11. Use setBattingAverage to change it to 0.2345. 12. Use showAll to display the data values. 13. Tell the user you’re using setEra to change it to 5.678. 14. Use setEra to change it to 5.678. 15. Use showAll to display the data values. Additional Requirement: Use the const modifier for member functions that do not write to a data member to guarantee the data members are protected. Report Put all five files

"96% of our customers have reported a 90% and above score. You might want to place an order with us."

Essay Writing Service
Affordable prices

You might be focused on looking for a cheap essay writing service instead of searching for the perfect combination of quality and affordable rates. You need to be aware that a cheap essay does not mean a good essay, as qualified authors estimate their knowledge realistically. At the same time, it is all about balance. We are proud to offer rates among the best on the market and believe every student must have access to effective writing assistance for a cost that he or she finds affordable.

Caring support 24/7

If you need a cheap paper writing service, note that we combine affordable rates with excellent customer support. Our experienced support managers professionally resolve issues that might appear during your collaboration with our service. Apply to them with questions about orders, rates, payments, and more. Contact our managers via our website or email.

Non-plagiarized papers

“Please, write my paper, making it 100% unique.” We understand how vital it is for students to be sure their paper is original and written from scratch. To us, the reputation of a reliable service that offers non-plagiarized texts is vital. We stop collaborating with authors who get caught in plagiarism to avoid confusion. Besides, our customers’ satisfaction rate says it all.

© 2022 Homeworkcrew.com provides writing and research services for limited use only. All the materials from our website should be used with proper references and in accordance with Terms & Conditions.

Scroll to Top