This assignment has been designed so that you understand the concept of using dynamic memory allocation in C++. After the completion of this assignment you should have a good grasp on:
o Array of Objects
o Use of new Operator for dynamic memory allocation in C++, for user-defined types.
o Use of delete Operator in C++, to free the memory allocated.
o Making your own header file and use it in your other program.
o Use of stream manipulator(s)
Write a C++ program that tells the teams qualified for a tournament’s semi finals.
Your program should ask the user about the number of teams included in the tournament. After taking input from the user your program should dynamically allocate the memory for the number of teams.
Take the input of number of matches won and loss during previously played rounds by the teams.
The points will be granted to each team according to the match status as follows:
Match status Points
A Team won a match will be granted 4 points, for draw 2 points will be given to each Team whereas no point is granted if a Team losses a match.
Your program should include a Class Team with the following Private data members.
o country //of which country the team belongs to
Where the noOfTeams should be static and will be incremented on the creation of each object. The incremented value of noOfTeams should be assigned to team_id in the constructor’s definition. This is how it generates and assigns the team_id for each new Team.
Class Team should have the following public member function.
This function will calculate the points of each Team after taking input from the user about the number of matches_played, won and loss during the tournament.
Your program should compare points attained by teams with each other and hence find out the top four teams and display them as a qualifying team for the semi finals.
Write the Setter functions to set or assign values to country, matches_played, won, loss and point of the Class Team.
Write the Getter functions to get value of country, matches_played, won, loss, and point of the Class Team.
Write constructor of the Class Team to initialize the data members.
Also write destructor for the Class Team.
Define the Class Team in a separate header file and include it into your main program.
Use stream manipulator, setw(5), to format your output.
How to create and include header file?
Define your class named Team in one file and save this file with a .h extension and you include this file as a Header File in your .cpp file
How you can create your own header file:
Create a folder with a name as “Assignment8
Open your Dev c++ and write this program
EXAMPLE FOR CREATING YOUR OWN HEADER FILE:
o After writing this program save this file in a folder “Assignment8 as myHeaderFile.h, You can also compile the program to check errors..
Suppose if you create the folder “Assignment8 in Drive D:
The path will be “D:\Assignment8\myHeaderFile.h.