Monday, February 21, 2011

Assignment # 3

Create class Player with following attributes:
string Name
// Below are skills for a cricket player valid range for a skill is 1 to 10
int Batting
int Bowling
int Fielding
int Running
// Valid range 0.00 to 100.00
double RunningAverage
// Valid range 2.00 to 10.00
double BowlingAverage
//Valid range is from 0 to 15
static int playerNumber=0;

Provided Behaviors are:
private int RandomNumber(int min, int max)
        {
            Random random = new Random();
            return random.Next(min, max);
        }
        private double RandomNumber()
        {
            Random random = new Random();
            return random.NextDouble();
        }


1.       Create a null parameter(default) constructor to that sets player name to as “Player”+PlayerNumber and increments playerNumber static attribute, it also sets player skills attributes to random values.
2.       Create a constructor that takes player’s name as parameter and fill reset of the values randomly.
3.       create a constructor that takes all player’s name and batting skills as parameters and fills rest of the attributes randomly
4.       Create a constructor  that takes player’s  name and bowling skills as parameters and fills rest randomly
5.       Create a behavior / method displaySmary() that display player’s Name and summary of his skills
6.       Create several players by using different constructors you have created and call displaySummary() method.

1 comment:

  1. Assalam o Alaikum Sir Could you please explain how to "Create a null parameter(default) constructor to that sets player name to as “Player”+PlayerNumber and increments playerNumber static attribute, it also sets player skills attributes to random values."

    Naveed Ekram (Repeater)

    ReplyDelete