Assignment No. 03
Semester: Fall 2019
CS304- Object Oriented Programming
Total Marks: 20
Due Date: 16/01/2020
The objective of this assignment is:
To give you the idea of practical implementation of C++ Inheritance and Polymorphism.
• Your assignment should be in .CPP format (Any other formats like scan images, PDF, zip, doc, rar and bmp etc. will not be accepted).
• Save your assignment with your ID (e.g. bc000000000.CPP).
• No assignment will be accepted through email.
Rules for Marking:
It should be clear that your assignment will not get any credit if:
• The assignment is submitted after due date.
• The submitted assignment does not open, execute or file is corrupted.
• Your assignment is copied from internet, handouts or from any other student.
(Strict disciplinary action will be taken in this case).
This assignment covers Lecture # 22-29.
Assignment No. 03
In continuation of scenario of PSL (Pakistan Super League) given in Assignment 1, you are required to write a C++ program that should contain three classes: Player, Batsman and Bowler, where Player should be base class and Batsman and Bowler should be its derived classes. The detail of data members and member functions for each class is provided in the given table.
|Class||Data Members||Member Functions|
|Player||• Name of Player, • Code of Player• Age of Player||• Default Constructor • Setter functions to set values of data members of this class. • Getter functions to get the values of data members of this class. • A function to set data of a player. •A function to display data of a player.|
|Batsman||• Innings played • Runs Scored • Batting Average||• Default Constructor • A function to set data of batsman. • A function to calculate batting average of a batsman. • A function to display data of a batsman.|
|Bowler||• Runs Conceded • Total Overs • Bowling Average||• Default Constructor • A function to set data of bowler. • A function to calculate bowling average of a bowler. • A function to display data of bowler.|
• You have to use concept of Polymorphism to generate the sample output.
• Use following formulas to calculate Batting and Bowling average of batsman and bowler, where Total Innings and Total Overs should be non-zero.
Batting Average = Runs Scored / Total Innings
Bowling Average = Total number of runs conceded / Total Overs
Best of luck!
NOTE: Do not put any query on MDB about this assignment, if you have any query then email at [email protected]. Furthermore, if any student found cheating from any other student or from online forums then he/she will be awarded ZERO right away and strict disciplinary action will be taken against the student.
Deadline: Your assignment must be uploaded/submitted on or before 16th Jan, 2020.