Write a base class named dairyanimal

Assignment Help C/C++ Programming
Reference no: EM13810344

Write a base class named DairyAnimal and two classes, Goat and Cow that inherit from it. You may use one file, or a multi-file project; whichever is easier for you.

1. Declare a DairyAnimal class a. Write a base class named DairyAnimal that has the following data members:

                float age;            //  years             int weight;          // weight of animal in pounds  int food;               // food eaten each day in pounds

b. And the following functions:

DairyAnimal();                                  // set age to 1.0F, weight to 1000, and food to 0 DiaryAnimal(float a, int w);                // overloaded constructor lets you set age and weight void feed(int f);                                 // pounds of food fed to the animal per day float milk();                                        // gallons of milk produced per day =  weight / food

c. Write two tests:  1) Display the amount of milk produced per day using an object created with the default constructor and 20 pounds of food.  2) Display the milk produced using an object created with the overloaded constructor and with age = 1, weight = 100 and lbsFood = 2.

2. Use inheritance to declare a Cow class

a. Override the milk function to use the following calculations:?If the age is 1 or more and 10 or less, gallons of milk = 0.5 * weight / food?Otherwise, gallons of milk = 0

d. Write tests for a: 1) 0.9 year old cow (any weight and amount of food. 2) 1 year old, 900 pound cow which is fed 15 pounds of food. 3) A 10 year old, 1100 pound cow, fed 25 pounds. 4) 10.1 year old cow (any weight and amount of food).

3. Use inheritance to declare a Goat class

a. This class will use DairyAnimal as a base class and inherit the public functions. Decide whether or not you will need to write new constructors.

b. Override the milk function to use the following calculations:?If the age is 0.7 or more and 10 or less, gallons of milk = weight / food?Otherwise, gallons of milk = 0.

Can you call the base class milk function?

c. Write the same four tests as for the Cow class, but use the following weights and amounts of food:

2) weight = 90 pounds, food = 1 pound

3) weight = 110 pounds, food = 2 pounds.

Reference no: EM13810344

Questions Cloud

Situation facing mensa at the time of the case : Describe the situation facing Mensa at the time of the case. This should include the major issues facing the company and the decisions that need to be made.
Statement regarding executive stock-lower risk free rates : Lower risk free rates results in __________ Put Option prices and ______ Call Option Prices. Which statement regarding executive stock options is correct?
Best strategic planning and implementation : Explain the BEST strategic planning and implementation/execution you have observed. Discuss fully. (2) Explain the WORST strategic planning and implementation/execution you have observed. What would you have done differently? Be specific. NOTE: Do..
Scope of project on upgrading office center : Define the scope of the project on upgrading a office center in which you have 7 months to complete include the project goals and objectives, deliverables, tasks, costs, deadlines, and expected main staffing and non-staffing resources needed.
Write a base class named dairyanimal : Write a base class named DairyAnimal and two classes, Goat and Cow that inherit from it. You may use one file, or a multi-file project; whichever is easier for you
Achieving innovation in project-based firms : Which of the approaches for achieving innovation in project-based firms is the most viable across the greatest variety of scenarios? Why? The approaches are the Linear-rational approach, and the Organic approach.
Setting the price on a new outpatient service : Assume that managers of Fort Winston Hospital are setting the price on a new outpatient service. Here are the relevant data estimates: Variable cost per visit $5.00 Annual direct fixed costs $500,000 Annual overhead allocation $50,000 Expected annual..
Create two function for converting between units of distance : It's often necessary to convert between units. In this exercise, you will create two functions for converting between units of distance. The first function will be called ConvertMilesToKilometers(), which will accept one parameter for the number o..
Safety and occupational health professional : You are the safety and occupational health professional for your city's Health Department. You received a call from a major food distribution warehouse that some employees are complaining of dizziness and feeling sick.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd