Develop and apply an appropriate and useful inheritance hierarchy

  

Develop and apply an appropriate and useful inheritance hierarchy.

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   

Get 20% Discount on This Paper
Pages (550 words)
Approximate price: -

Try it now!

Get 20% Discount on This Paper

We'll send you the first draft for approval by at
Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

Custom Writings Help is a Quality-Oriented Company in Online Writing as a result of hiring exceptional professionals to execute clients' tasks.

Essays

Research Papers

At Custom Writings Help,We understand the struggle of research paper writing, and that is why at Custom WritingS Help, we are all out to help you. We pride ourselves on having a team of clinical writers. The stringent and rigorous vetting process ensures that only the 'BEST' Writers are chosen for the job. We have highly qualified Ph.D. and MA writers working with us; we equally offer these experienced writers specific bonuses and incentives to make them deliver highly original, unique, and informative content at reasonably low prices.

Admissions

Thesis Writing Service

Worlwide, Many Masters Students are struggling with Thesis Completion. A thesis is likely to be the longest and most challenging piece of work a student has ever completed. However, unlike essays and other assignments, a student can pick a particular interest topic and work on their initiative. Fortunately, we are there for you. At Custom Writings Help, you are assured of an authentic, imaginative, informative, linguistically great, and advantageous thesis that adheres to all your needs. So, why continue considering different writers when you have discovered the best in the field?

Editing

Custom Papers

Not a single student can avoid writing custom papers. However, a total lack of experience, skills, and time makes it very hard to produce a superb writing piece. Therefore, if you are seeking professional help, turn to us. Our specialized and experienced writers compose a variety of model papers, including custom essays, college term papers, research papers, book reports, MBA essays, executive summaries, dissertations, Ph.D. theses, admission essays, and research proposals for college and university students at any level.

Coursework

Essay Writing

Most of the students disregard the critical principles of essay writing and compose papers below sensible guidelines. Therefore, with Custom Writings Help, one should not worry about his/her essay. Our Writers compose informative and engaging content on all complexities and topics. We write meaningful and smart essays while prioritizing all aspects that bring about a good grade, such as impeccable grammar, proper structure, zero-plagiarism, and conformance to guidelines.

Coursework

Coourse Work Writing

Don't let the seemingly never-ending onslaught of writing assignments get you down. If you are looking where to get course work assistance online, the writers at Custom Writings Help are here to assist you with all of your writing needs. We undertake to unique delivery of papers that meet the professor's requirements. The content is proofread, edited, and checked plagiarism before submission to customers. No matter how big or small your work is, we will deliver on time. Try US Now! !

Coursework

Dissertation Writing Service

High-Quality Dissertation Writing Services are rare. They require Ph.D. academicians – not easily found. However, are an exception. The years, time, and resources we have invested in the dissertation world has given us a competitive advantage over others. Choose to come to Custom Writings Help; You will find perfect Ph.D. consultants who have written hundreds of dissertations theses ready to help you. Let our dissertation-writing services help you craft your dissertation, for you are assured we will give you the results.