Advertisement
NicholasB

Dairy

Mar 16th, 2025
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.60 KB | Software | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. // globals!
  7. const int dailyEstimate = 15; // In litres and when well fed.
  8.  
  9. // base class!
  10. class Animal {
  11.     public: int age;
  12.     public: string name;
  13.     public: string breed;
  14.  
  15. };
  16.  
  17. class DairyCow : public Animal {
  18.     protected: int milkProduction;
  19.     public: int feedingCost;
  20.  
  21.     // estimates milk production based on the cow’s breed and feeding cost
  22.     public: int  calculateMilkYield( DairyCow cow ) {
  23.         cout << "Ze cow of name:  !!" << cow.name << endl;
  24.         cout << "Estimate output from age, breed and feeding cost" << endl;
  25.  
  26.     }
  27. };
  28.  
  29. int main() {
  30.     DairyCow cow;
  31.  
  32.     // assign values to props: name, breed, age, feedingCost:
  33.     // @TODO the milkProduction is derived from the above values.
  34.     cout << "Please enter the FOUR cow details ( props ) below ::: " << endl;
  35.  
  36.     cout << "Enter Cow name : " << endl;
  37.     cin >> cow.name;
  38.     cout << "Entry assignment : Cow name  === " << cow.name << endl;
  39.  
  40.     cout << "Enter Cow breed eg Friesian, Jersey, Sahiwal etc : " << endl;
  41.     cin >> cow.breed;
  42.     cout << "Entry assignment : Cow breed  === " << cow.breed << endl;
  43.  
  44.     cout << "Enter Cow age eg 7 (for 7 yrs ): " << endl;
  45.     cin >> cow.age;
  46.     cout << "Entry assignment : Cow age  === " << cow.age << " years" << endl;
  47.  
  48.     cout << "Enter Cow feedingCost ( Kshs): " << endl;
  49.     cin >> cow.feedingCost;
  50.     cout << "Entry assignment : Cow feedingCost  === " << cow.feedingCost << " Kshs" << endl;
  51.     cout << "Exec calculateMilkYield ..... " << endl;
  52.  
  53.     cow.calculateMilkYield( cow );
  54.  
  55. }
  56.  
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement