//******************************************************************************
//
// CS 240C : Spring 2003 Ohio University Travis Dillon
// Project 3 : Animal Homes
// file : lemur.cc
// started : 05-07-03
//
//******************************************************************************
#include "lemur.h"
Lemur::Lemur(int ham, int cost, int hi, int tr)
{ //this c-tor is used when reading data from the file
//the Lemur object is instantiated with the new call
id = 5;
num_ham = ham;
price = cost;
height = hi;
tree = tr;
}
void Lemur::input()
{ //user inputs all the attributes for the bat cave here
cout << "\nLet's make you a nice ring-tailed lemur tree house."
<< "\nHow many feet tall does the tree need to be? ";
cin >> height;
cout << "What kind of tree would you like?"
<< "\n1. Elm"
<< "\n2. Pine"
<< "\n3. Oak"
<< "\n4. Poplar"
<< "\n5. Maple"
<< "\n : ";
cin >> tree;
if(tree > 5 || tree < 1)
{
cout << "Invalid input, you get Oak";
tree = 3;
}
cout << "How many hammocks do you need? ";
cin >> num_ham;
price = set_price(num_ham, height, tree);
cout << "The total price will be $" << price;
}
void Lemur::output()
{ //output when user wants to see all the homes ordered
cout << "\nRing-Tailed Lemur tree house"
<< "\ntree height = " << height
<< "\ntree type = ";
switch(tree)
{
case 1: cout << "elm"; break;
case 2: cout << "pine"; break;
case 3: cout << "oak"; break;
case 4: cout << "poplar"; break;
case 5: cout << "maple"; break;
default: cout << "Error Error Error"; break;
}
cout << "\nnumber of hammocks = " << num_ham;
cout << "\ntotal price = $" << price;
cout << endl;
}
void Lemur::print(ofstream& fout)
{ //output member variables to output file to be read in on next start up
fout << num_ham << endl
<< price << endl
<< height << endl
<< tree << endl;
}
int Lemur::set_price(int ham, int hi, int tr)
{ //the actuall price of the home
return(207*ham + tr*hi*100);
}