Currently, you are using composition by creating an instance of a vector / ArrayList inside your AddressBook. This works fine but if we really think about it, and AddressBook is a collection like a stack or a queue or a vector for that matter. Your task is to: C++ derive AddressBook from vector. In other words, use the vector as a base class and derive AddressBook from it. This means that you will need to remove the Vector from the private section of your class. You are going to have to make some fundamental changes to your AddressBook so that you are using the vector / ArrayList functionality to store and retrieve people. In other words, you should be accessing the ArrayList / vector using this. C++ people, don’t forget you are returning pointers in the accessors of the AddressBook class Test your AddressBook the same way you did for assignment 2. If you have coded everything properly it should work the same. Task 2 Create class called Player that is derived from Person. The Player class should hold the following information Average Slugging Percentage On Base Percentage All should be double data types Constructors Default Player(string first, string last, string address, double average, double slugging, double onBase) You should delegate the default constructor to eliminate multiple code paths. Mutators void setAverage(double avg void setSlugging(double slug) void setOBP(double OnBase) Accessors double getAverage() double getSlugging() double getOBP() print function In the Person class add a public function called print. This function will print out the person’s first, last, address. This function should be a virtual function or method. In essence all overridden methods in Java are virtual Java students don't need to do anything except override the method. In Player override the print function so that you print out the players name, address, average, slugging %, On base %. To print the information from the Person class you should call the print function from the Player print function. Test your new class by creating a couple of Players. Make sure you test all functionality and that your print function prints everything from both Person and Player.
Types of Linked List
A sequence of data elements connected through links is called a linked list (LL). The elements of a linked list are nodes containing data and a reference to the next node in the list. In a linked list, the elements are stored in a non-contiguous manner and the linear order in maintained by means of a pointer associated with each node in the list which is used to point to the subsequent node in the list.
Linked List
When a set of items is organized sequentially, it is termed as list. Linked list is a list whose order is given by links from one item to the next. It contains a link to the structure containing the next item so we can say that it is a completely different way to represent a list. In linked list, each structure of the list is known as node and it consists of two fields (one for containing the item and other one is for containing the next item address).
03 Inheritance / Polymorphism
Task 1
Currently, you are using composition by creating an instance of a
C++ derive AddressBook from vector. In other words, use the vector as a base class and derive AddressBook from it. This means that you will need to remove the Vector from the private section of your class.
You are going to have to make some fundamental changes to your AddressBook so that you are using the vector / ArrayList functionality to store and retrieve people. In other words, you should be accessing the ArrayList / vector using this. C++ people, don’t forget you are returning pointers in the accessors of the AddressBook class
Test your AddressBook the same way you did for assignment 2. If you have coded everything properly it should work the same.
Task 2
Create class called Player that is derived from Person. The Player class should hold the following information
- Average
- Slugging Percentage
- On Base Percentage
All should be double data types
Constructors
- Default
- Player(string first, string last, string address, double average, double slugging, double onBase)
You should delegate the default constructor to eliminate multiple code paths.
Mutators
- void setAverage(double avg
- void setSlugging(double slug)
- void setOBP(double OnBase)
Accessors
- double getAverage()
- double getSlugging()
- double getOBP()
print function
In the Person class add a public function called print. This function will print out the person’s first, last, address. This function should be a virtual function or method. In essence all overridden methods in Java are virtual Java students don't need to do anything except override the method.
In Player override the print function so that you print out the players name, address, average, slugging %, On base %.
To print the information from the Person class you should call the print function from the Player print function.
Test your new class by creating a couple of Players. Make sure you test all functionality and that your print function prints everything from both Person and Player.
Can you help me solve this problem in C++ forms using the Inheritance / Polymorphism
If you decide to create in Java then as least please transform the Java into C++ and explain to me in C++ form because I never took Java.

Trending now
This is a popular solution!
Step by step
Solved in 2 steps









