Question

In: Computer Science

1. write a class called football player with variables number, weight, height inside. Then make child...

1. write a class called football player with variables number, weight, height inside. Then make child classes for football player, one called defensive player, which will have sacks and interceptions as variables, and offensive player, which will have yards and fumbles as variables

Solutions

Expert Solution

INPUT CODE:


OUTPUT:

CODE TO COPY:

#include <iostream>
using namespace std;

class Football_Player{//PARENT CLASS
   protected:
   int number,weight,height;
  
   public:
       void setNumber(int x){//SETTING DATA MEMBERS
           number=x;
       }
       void getNumber(){
           cout<<number;
       }
};

class Defensive_Player : public Football_Player{//DERIVED CLASS
   int sacks,interceptions;
};


class Offensive_Player :public Football_Player{//DERIVED CLASS
   int yards,fumbles;
  
};

int main(){

Offensive_Player o1;//INTIALIZING OBJECT OF DERIVED CLASS

o1.setNumber(20);//USING DATA FUNCTION OF PARENT CLASS
  
o1.getNumber();  
  
}


Related Solutions

There are two variables in this data set. Variable Definition Height Height in inches Weight Weight...
There are two variables in this data set. Variable Definition Height Height in inches Weight Weight in pounds Using Excel, compute the standard deviation and variance (both biased and unbiased) for height and weight. Height weight 53 156 46 131 54 123 44 142 56 156 76 171 87 143 65 135 45 138 44 114 57 154 68 166 65 153 66 140 54 143 66 156 51 173 58 143 49 161 48 131
Write the code of: – an abstract class called Creature – classes Player and Monster (derived...
Write the code of: – an abstract class called Creature – classes Player and Monster (derived from Creature) – classes WildPig and Dragon (derived from Monster) In the Creature class – Define a string member, Creature Name, to store the class Creature’s name.(name should be dynamically allocated) – Define Two virtual pure functions • void DoAction() : Print the action of the object, and the actions have to be different from different classes. • void DrawOnScreen() : Print the object’s...
The average weight of a professional football player in 2009 was 246.2 pounds. Assume the population...
The average weight of a professional football player in 2009 was 246.2 pounds. Assume the population standard deviation is 25 pounds. A random sample of 32 professional football players was selected. Complete parts a through e. a. Calculate the standard error of the mean. b. What is the probability that the sample mean will be less than 234 pounds?
The average weight of a professional football player in 2009 was 254.9 pounds. Assume the population...
The average weight of a professional football player in 2009 was 254.9 pounds. Assume the population standard deviation is 40 pounds. A random sample of 32 professional football players was selected. Complete parts a through e. a. Calculate the standard error of the mean. ​(Round to two decimal places as​ needed.) b. What is the probability that the sample mean will be less than 238 ​pounds? ​(Round to four decimal places as​ needed.) c. What is the probability that the...
Create a class called Height Copy the code for Height given below into the class. Remember...
Create a class called Height Copy the code for Height given below into the class. Remember – test the methods as you go Take a few minutes to understand what the class does. There are comments where you will have to be changing code. A list of changes are given Change the setFeet and setInches mutators to make sure the height and width will not be less than 0, no matter what is passed in to it Change constructor that...
Create a class called “Cycle” which has two instance integer variables as properties, “numberOfWheels” and “weight.”
Programming Problem 2 - Cycle[A] Create a class called “Cycle” which has two instance integer variables as properties, “numberOfWheels” and “weight.” Create a constructor with two parameters, using the same variable names in the parameter list. Assign each variable to numberOfWheels” and “weight” respectively. Write a separate application to test the class and display its properties. Note: Do not change the names of the instance variables or the variables listed in the constructor’s parameter list.[B] Edit your class Cycle by...
(java) Write a class called CoinFlip. The class should have two instance variables: an int named...
(java) Write a class called CoinFlip. The class should have two instance variables: an int named coin and an object of the class Random called r. Coin will have a value of 0 or 1 (corresponding to heads or tails respectively). The constructor should take a single parameter, an int that indicates whether the coin is currently heads (0) or tails (1). There is no need to error check the input. The constructor should initialize the coin instance variable to...
#Write a class called "Burrito". A Burrito should have the #following attributes (instance variables): # #...
#Write a class called "Burrito". A Burrito should have the #following attributes (instance variables): # # - meat # - to_go # - rice # - beans # - extra_meat (default: False) # - guacamole (default: False) # - cheese (default: False) # - pico (default: False) # - corn (default: False) # #The constructor should let any of these attributes be #changed when the object is instantiated. The attributes #with a default value should be optional. Both positional #and...
Write a class called Pen that contains the following information: Private instance variables for the price...
Write a class called Pen that contains the following information: Private instance variables for the price of the pen (float) and color of the pen (String). A two-argument constructor to set each of the instance variables above. If the price is negative, throw an IllegalArgumentException stating the argument that is not correct. Get and Set methods for each instance variable with the same error detection as the constructor. public class Pen {
1.For Python Which statement(s) are true regarding private class variables? private variables can be accessible inside...
1.For Python Which statement(s) are true regarding private class variables? private variables can be accessible inside the class. private variables can be accessible outside the class. private variable values can be changed directly outside of the class private variables can be changed outside the class through set methods. 2. In the following code, def A: def __init__(self):      __a = 1      self.__b = 1      self.c = 1      __d__ = 1 # Other methods omitted Which of the following is a private...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT