help w/ single inheritence?

August 2, 2009 at 18:02:02
Specs: Windows XP
hi i was wondering if anyone could possibly help me or give me some suggestions on how to change from a program WITHOUT inheritance to one WITH single inheritance.
ive written the program here without already and with the first part of the pollencounter class but am stumped as how to dervive it. Its supposed to be weatherstation:public pollencounter
but with an array, im completely confused as how to do so.
ANY help at all would be taken so gratefully!

#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

class PollenCounter

double GetHighCount() {return HighCount;}
void SetHighCount(double High) {HighCount = High;}
double GetLowCount() {return LowCount;}
void SetLowCount(double Low) {LowCount = Low;}

//Other Method
void AverageCount(double AverageCount)
AverageCount = (HighCount+LowCount)/2;
double HighCount;
double LowCount;

class WeatherStation
string StationDesignation;
string StationAgent;
double Temperature;
double HighCount;
double LowCount;
double AverageCount;
//defines a class that represents a single weather stations
WeatherStation() { ; }

WeatherStation(string ID, string Agent, double Degree, double High, double Low, double Average)
StationDesignation = ID;
StationAgent = Agent;
Temperature = Degree;
HighCount = High;
LowCount = Low;
AverageCount = Average;
void SetDesignation(string ID) { StationDesignation = ID; }
void SetAgent(string Agent) { StationAgent = Agent; }
void SetTemperature(double Degree) { Temperature = Degree; }
void SetHighCount(double High) { HighCount = High; }
void SetLowCount(double Low) { LowCount = Low; }
void SetAverageCount(double Average){ AverageCount = Average; }

string GetDesignation() { return StationDesignation; }
string GetAgent() { return StationAgent; }
double GetTemperature() { return Temperature; }
double GetHighCount() { return HighCount; }
double GetLowCount() { return LowCount; }
double GetAverageCount() { return AverageCount; }

void MainMenu();
int AddStations(WeatherStation[]);
void PostStationInfo(WeatherStation[], int);
void DailyPollenCounter(WeatherStation[], int);
//declaring functions
const int MAXSIZE = 100;
//declaring a constant maximum value of weather stations

int main()//main program
WeatherStation StationList[MAXSIZE];
string Command;
int Number_Station=0;

for( ; ; ) //using a for loop to respond to users input/command
cout << "Enter Command: ";
getline(cin, Command);
if(Command == "Quit")
else if(Command == "Add Stations")
Number_Station = AddStations(StationList);
else if(Command == "Post Station Info")
PostStationInfo(StationList, Number_Station);
else if (Command == "Daily Pollen Count")
return 0;

void MainMenu() //defining the main menu and what choices the user has to pick from
cout << "\nMain Menu\n\n";
cout << "Choices.........\n";
cout << "--------------------\n";
cout << "Add Stations\n";
cout << "Post Station Info\n";
cout << "Daily Pollen Count\n";
cout << "Quit\n";
cout << "---------------------\n\n";


int AddStations(WeatherStation StationList[])//defining the function for adding stations and both naming them and their contact person
string ID, Agent;
int i;
cout << "\n****** Enter Station Information Below. Enter 'Stop' To Quit ******" << endl;
for(i = 0 ; i < MAXSIZE ; i++)
cout << "\nEnter Station Designation: ";
getline(cin, ID);//reads an entire line of input from the user
if (ID == "Stop")
cout << "Enter Contact Person: ";
getline(cin, Agent);

StationList[i].SetDesignation(ID);//storing information
return i;

void PostStationInfo(WeatherStation StationList[], int Size)// defining the function that takes user's inputed temperatures and stores them in an array
double Degree, HighCount, LowCount, High, Low;
cout << "\n\nPlease enter temperature in Farenheits \n\n";
for (int i=0; i < Size; i++)
cout << "Weather Station "<<StationList[i].GetDesignation() <<": \n"; //calling back stored numbers
cout << "Weather Agent "<<StationList[i].GetAgent() <<": \n";
cout << "Temperature: ";
cin >> Degree; //get input of temperature from user
StationList[i].SetTemperature(Degree); //storing data
cout << "Pollen Count:\n\tHigh:";
cin >> High;
cout << "\tLow:";
cin >> Low;
cin.ignore(100, '\n'); //Clear Buffer

void DailyPollenCounter(WeatherStation StationList[], int Size)
double High;
double Low;
int i;

for (int i=0; i < Size; i++)
double Average;
Average = (StationList[i].GetHighCount()+StationList[i].GetLowCount())/2;

for (int i=0; i < Size; i++)
cout << setiosflags (ios::showpoint) << setprecision (3)<< setprecision(3);
cout << "Weather Station: "<<StationList[i].GetDesignation()<<" \t " <<StationList[i].GetAverageCount()<<"\n";

See More: help w/ single inheritence?

Report •

August 5, 2009 at 06:53:14
You want what to inherit what, now?

Report •
Related Solutions

Ask Question