Browse over 20 million
homework answers & study documents

Computer Science

C++ Visual Studio Project DairyAnimal

Type

Lab

Rating

Showing Page:
1/6
CPPDairyAnimal.cpp
// CPPDairyAnimal.cpp : Denes the entry point for the console application.
//
#include "stdafx.h"
#include "DairyAnimal.h"
#include "Cow.h"
#include "Goat.h"
#include <iostream>
using namespace std;
//Display the amount of milk produced per day using an object created with the default
constructor and 20 pounds of food
void amountOfMilkProducedPerDay(){
DairyAnimal dairyAnimal;
dairyAnimal.feed(20);
cout << "The amount of milk produced per day using an object created with the default
constructor and 20 pounds of food: " << dairyAnimal.milk()<< endl;
}
//Display the milk produced using an object created with the overloaded constructor and with age
= 1, weight = 100 and lbsFood = 2
void displayMilkProduced()
{
DairyAnimal dairyAnimal(1, 100);
dairyAnimal.feed(2);
cout << "The milk produced using an object created with the overloaded constructor and
with age = 1, weight = 100 and lbsFood = 2: " << dairyAnimal.milk()<< endl;
}
//0.9 year old cow (any weight and amount of food.
void milkProducedByCow1()
{
Cow cow(0.9f, 10);
cow.feed(10);
cout << "The milk produced by 0.9 year old cow (any weight and amount of food): " <<
cow.milk()<< endl;
}
//1 year old, 900 pound cow which is fed 15 pounds of food.
void milkProducedByCow2()
{
Cow cow(1, 900);
cow.feed(15);
cout << "The milk produced by 1 year old, 900 pound cow which is fed 15 pounds of
food.: " << cow.milk()<< endl;
}
//A 10 year old, 1100 pound cow, fed 25 pounds.
void milkProducedByCow3()
{
Cow cow(10, 1100);

Sign up to view the full document!

lock_open Sign Up
cow.feed(25);
cout << "The milk produced by 10 year old, 1100 pound cow, fed 25 pounds: " <<
cow.milk()<< endl;
}
//10.1 year old cow (any weight and amount of food).
void milkProducedByCow4()
{
Cow cow(10.1, 1100);
cow.feed(25);
cout << "The milk produced by 10.1 year old cow (any weight and amount of food): " <<
cow.milk()<< endl;
}
//0.9 year old goat (any weight and amount of food.
void milkProducedByGoat1()
{
Goat goat(0.9f, 10);
goat.feed(10);
cout << "The milk produced by 0.9 year old goat (any weight and amount of food): " <<
goat.milk()<< endl;
}
//1 year old, 90 pound goat which is fed 1 pounds of food.
void milkProducedByGoat2()
{
Goat goat(1, 90);
goat.feed(1);
cout << "The milk produced by 1 year old, 90 pound goat which is fed 1 pounds of food.:
" << goat.milk()<< endl;
}
//A 10 year old, 110 pound goat, fed 2 pounds.
void milkProducedByGoat3()
{
Goat goat(10, 110);
goat.feed(2);
cout << "The milk produced by 10 year old, 110 pound goat, fed 2 pounds: " <<
goat.milk()<< endl;
}
//10.1 year old goat (any weight and amount of food).
void milkProducedByGoat4()
{
Goat goat(10.1, 1100);
goat.feed(25);
cout << "The milk produced by 10.1 year old goat (any weight and amount of food): " <<
goat.milk()<< endl;
}
int _tmain(int argc, _TCHAR* argv[])
{
amountOfMilkProducedPerDay();
displayMilkProduced();
//cow test cases
milkProducedByCow1();
milkProducedByCow2();
milkProducedByCow3();

Sign up to view the full document!

lock_open Sign Up

Sign up to view the full document!

lock_open Sign Up

Unformatted Attachment Preview

CPPDairyAnimal.cpp// CPPDairyAnimal.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include "DairyAnimal.h"#include "Cow.h"#include "Goat.h"#include using namespace std;//Display the amount of milk produced per day using an object created with the default constructor and 20 pounds of foodvoid amountOfMilkProducedPerDay(){DairyAnimal dairyAnimal;dairyAnimal.feed(20);cout << "The amount of milk produced per day using an object created with the default constructor and 20 pounds of food: " << dairyAnimal.milk()<< endl;}//Display the milk produced using an object created with the overloaded constructor and with age = 1, weight = 100 and lbsFood = 2void displayMilkProduced(){DairyAnimal dairyAnimal(1, 100);dairyAnimal.feed(2);cout << "The milk produced using an object created with the overloaded constructor and with age = 1, weight = 100 and lbsFood = 2: " << dairyAnimal.milk()<< endl;}//0.9 year old cow (any weight and amount of food. void milkProducedByCow1(){Cow cow(0.9f, 10);cow.feed(10);cout << "The milk produced by 0.9 year old cow (any weight and amount of food): " << cow.milk()<< endl;}//1 year old, 900 pound cow which is fed 15 pounds of food. void milkProducedByCow2(){Cow cow(1, 900);cow.feed(15);cout << "The milk produced by 1 year old, 900 pound cow which is fed 15 pounds of food.: " << cow.milk()<< endl;}//A 10 year old, 1100 pound cow, fed 25 pounds. void milkProd ...
Purchase document to see full attachment

Anonymous
I was on a very tight deadline but thanks to Studypool I was able to deliver my assignment on time.

Anonymous
I did not know how to approach this question, Studypool helped me a lot.

Anonymous
Very good notes! They were very useful as my study guides.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4