//******************************************************************************
//
// CS 240C : Spring 2003 Ohio University Travis Dillon
// Project 3 : Animal Homes
// file : penguin.cc
// started : 05-07-03
//
//******************************************************************************
#include "penguin.h"
Penguin::Penguin(int sp, int tv, int cost, int te)
{ //this c-tor is used when reading data from the file
//the Penguin object is instantiated with the new call
id = 6;
num_spa = sp;
num_tv = tv;
price = cost;
temp = te;
}
void Penguin::input()
{ //user inputs all the attributes for the bat cave here
cout << "\nLet's make you a nice penguin igloo."
<< "\nWhat temperature in farenheit would you like inside the igloo? ";
cin >> temp;
temp = check_temp(temp);
cout << "How many hot tubs would you like? ";
cin >> num_spa;
cout << "How many televisions would you like? ";
cin >> num_tv;
price = set_price(num_spa, num_tv, temp);
cout << "The total price will be $" << price;
}
void Penguin::output()
{ //output when user wants to see all the homes ordered
cout << "\nPenguin igloo"
<< "\ninside temperature = " << temp
<< "\nnumber of hot tubs = " << num_spa
<< "\nnumber of televisions = " << num_tv
<< "\ntotal price = $" << price
<< endl;
}
void Penguin::print(ofstream& fout)
{ //output member variables to output file to be read in on next start up
fout << num_spa << endl
<< num_tv << endl
<< price << endl
<< temp << endl;
}
int Penguin::set_price(int spa, int tv, int te)
{ //the actuall price of the home
return(spa*1200 + tv*253 + abs(te*83));
}
int Penguin::check_temp(int& in)
{
if(in > 105){cout << "That's too hot. I'll make it 90.\n"; in = 90;}
if(in < -459){cout << "Too cold. I'll make it 20.\n"; in = 20;}
return in;
}