<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[CS304 Assignment 3 Solution and Discussion]]></title><description><![CDATA[<p dir="auto">Assignment No. 03<br />
Semester: Fall 2019<br />
CS304- Object Oriented Programming</p>
<p dir="auto">Total Marks: 20</p>
<p dir="auto">Due Date: 16/01/2020</p>
<p dir="auto">Objective<br />
The objective of this assignment is:<br />
To give you the idea of practical implementation of C++ Inheritance and Polymorphism.</p>
<p dir="auto">Uploading instructions:</p>
<p dir="auto">•	Your assignment should be in .CPP format (Any other formats like scan images, PDF, zip, doc, rar and bmp etc. will not be accepted).<br />
•	Save your assignment with your ID (e.g. bc000000000.CPP).<br />
•	No assignment will be accepted through email.</p>
<p dir="auto">Rules for Marking:</p>
<p dir="auto">It should be clear that your assignment will not get any credit if:</p>
<p dir="auto">•	The assignment is submitted after due date.<br />
•	The submitted assignment does not open, execute or file is corrupted.<br />
•	Your assignment is copied from internet, handouts or from any other student.<br />
(Strict disciplinary action will be taken in this case).</p>
<p dir="auto">Lectures Covered:</p>
<p dir="auto">This assignment covers Lecture # 22-29.</p>
<p dir="auto">Assignment No. 03</p>
<p dir="auto">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.</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>Class</th>
<th>Data Members</th>
<th>Member Functions</th>
</tr>
</thead>
<tbody>
<tr>
<td>Player</td>
<td>•	Name of Player,                  • Code of Player•	Age of Player</td>
<td>•	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.</td>
</tr>
<tr>
<td>Batsman</td>
<td>•	Innings played •	Runs Scored •	Batting Average</td>
<td>•	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.</td>
</tr>
<tr>
<td>Bowler</td>
<td>•	Runs Conceded •	Total Overs •	Bowling Average</td>
<td>•	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.</td>
</tr>
</tbody>
</table>
<p dir="auto">Solution Guidelines:<br />
•	You have to use concept of Polymorphism to generate the sample output.<br />
•	Use following formulas to calculate Batting and Bowling average of batsman and bowler, where Total Innings and Total Overs should be non-zero.<br />
Batting Average = Runs Scored / Total Innings<br />
Bowling Average = Total number of runs conceded / Total Overs</p>
<p dir="auto">Sample Output:</p>
<pre><code>Best of luck!
</code></pre>
<p dir="auto">NOTE:  Do not put any query on MDB about this assignment, if you have any query then email at <a href="mailto:cs304@vu.edu.pk" target="_blank" rel="noopener noreferrer nofollow ugc">cs304@vu.edu.pk</a>.  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.</p>
<p dir="auto">Deadline: Your assignment must be uploaded/submitted on or before 16th Jan, 2020.</p>
]]></description><link>https://community.secnto.com//topic/999/cs304-assignment-3-solution-and-discussion</link><generator>RSS for Node</generator><lastBuildDate>Mon, 08 Jun 2026 19:59:46 GMT</lastBuildDate><atom:link href="https://community.secnto.com//topic/999.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 16 Jan 2020 07:27:12 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to CS304 Assignment 3 Solution and Discussion on Thu, 16 Jan 2020 07:30:46 GMT]]></title><description><![CDATA[<p dir="auto"><a href="http://cpp.sh/87li4" target="_blank" rel="noopener noreferrer nofollow ugc">Compile Online C++ Code</a></p>
]]></description><link>https://community.secnto.com//post/2726</link><guid isPermaLink="true">https://community.secnto.com//post/2726</guid><dc:creator><![CDATA[zareen]]></dc:creator><pubDate>Thu, 16 Jan 2020 07:30:46 GMT</pubDate></item><item><title><![CDATA[Reply to CS304 Assignment 3 Solution and Discussion on Thu, 16 Jan 2020 07:28:14 GMT]]></title><description><![CDATA[<p dir="auto">Solution Idea:</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;string&gt;
using namespace std;
class Player{
private:
string name;
string code;
int Age;
public:
Player()
{
//………….
}
void setname()
{
cout"\nEnter Name: ";
cin&gt;&gt;name;
}
void setcode()
{
cout" Enter PlayerCode: ";
cin&gt;&gt; code;
}
void setAge()
{
cout" Enter Age: ";
cin&gt;&gt; Age;
}
string getname()
{
return name;
}
string getcode()
{
return code;
}
int getAge()
{
return Age;
}
void display()
{
// Display function for Player Class….
}
};
class Batsman:public Player{
private:
int Inning;
int Scored;
double B_Average;
public:
Batsman()
{
//………….
}
void setInning()
{
cout"Enter Inning: ";
cin&gt;&gt;Inning;
}
void setScored()
{
cout"Enter Runs: ";
cin&gt;&gt;Scored;
}
double cal_Average()
{
return B_Average = Scored/Inning;
}
virtual void display()
{
cout"\nDisplaying Batsman Information:\n..........................\n";
cout"Batsman name: "getname()endl;
cout"Batsman code: "getcode()endl;
cout"Batsman age: "getAge()endl;
cout"Batsman Average: "cal_Average()endl;
}
};
class Bowler:public Player{
private:
int Run, Over;
double L_Average;
public:
Bowler()
{
//.......
}
void setRun()
{
cout"Enter Runs Conceded: ";
cin&gt;&gt;Run;
}
void setOver()
{
cout"Enter Total Overs: ";
cin&gt;&gt;Over;
}
double cal_Average()
{
return L_Average = Run/Over;
}
virtual void display()
{
cout"\nDisplaying Bowler information:\n..........................";
cout"Bowler name: "getname()endl;
cout"Bowler code: "getcode()endl;
cout"Bowler age: "getAge()endl;
cout"Bowler Average: "cal_Average()endl;
}
};

int main()
{
int size, i;
char arr[size], check;
Batsman batsman;
Bowler bowler;

cout" How many Bowlers and Batsman data you want to enter? ";
cin&gt;&gt;size;

while(i&lt;size)
{
cout"\nEnter choice: B for batsman, L for Bowler: "endl;
cin&gt;&gt;arr[i];

if(arr[i] == 'b' || arr[i] == 'B')
{
cout"\nEnter following data for Batsman: "endl;
batsman.setname();
batsman.setcode();
batsman.setAge();
batsman.setInning();
batsman.setScored();
}
if(arr[i]=='l' || arr[i]== 'L' )
{
cout"\nEnter following data for bowler: "endl;

bowler.setname();
bowler.setcode();
bowler.setAge();
bowler.setOver();
bowler.setRun();
}
cout"\nDo you want to enter more data (Y for yes, N for No): ";
cin&gt;&gt;check;

if(check=='n' || check =='N' || i==size-1)
{
for (i=0; i&lt;size; i++)
{
if(arr[i] =='B' || arr[i] == 'b')
{
batsman.display();
}
if(arr[i] == 'L' || arr[i] == 'l')
{
bowler.display();
}
}
}
i++;
}

}
</code></pre>
]]></description><link>https://community.secnto.com//post/2725</link><guid isPermaLink="true">https://community.secnto.com//post/2725</guid><dc:creator><![CDATA[zareen]]></dc:creator><pubDate>Thu, 16 Jan 2020 07:28:14 GMT</pubDate></item><item><title><![CDATA[Reply to CS304 Assignment 3 Solution and Discussion on Thu, 16 Jan 2020 07:27:33 GMT]]></title><description><![CDATA[<p dir="auto"><a href="https://www.youtube.com/watch?v=CApMAE3iggs" target="_blank" rel="noopener noreferrer nofollow ugc">https://www.youtube.com/watch?v=CApMAE3iggs</a></p>
]]></description><link>https://community.secnto.com//post/2724</link><guid isPermaLink="true">https://community.secnto.com//post/2724</guid><dc:creator><![CDATA[zareen]]></dc:creator><pubDate>Thu, 16 Jan 2020 07:27:33 GMT</pubDate></item></channel></rss>