Sorry, guys I forgot to tag my code in the previous post. That's why I am making a new post with code-tag of course. Anyway, here is my programme and it is not working.
Code:
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
using namespace std;
class GreenStation {
double AirQualityIndex;
double PollenCount;
public:
GreenStation(){;}
GreenStation(double, double);
//Define mutators...
void SetPCount(double Count) { PollenCount = Count; }
void SetAQScore(double Score) { AirQualityIndex = Score; }
//Define accessors...
double GetPCount() { return PollenCount; }
double GetAQScore() { return AirQualityIndex; }
};
class WeatherStation : public GreenStation {
string StationDesignation; //Identifies the station
string StationAgent; //Who's responsible
double Temperature; //...and, of course, how hot is it?
public:
//Define some mutators...These member functions allow us to
// change values in the object...
void SetDesignation(string ID) { StationDesignation = ID; }
void SetAgent(string Agent) { StationAgent = Agent; }
void SetTemperature(double Degree) {Temperature = Degree; }
//Define some accessors...These member functions allow us to get
// at the internal values
string GetDesignation() { return StationDesignation; }
string GetAgent() { return StationAgent; }
double GetTemperature() { return Temperature; }
//Define a displayer...this will show the contents of the object
// in an easy to read format..
void Displayer();
};
class WeatherStationList {
vector<WeatherStation> List; //These two lines essentially implement the list...
vector<WeatherStation>::iterator ThroughTheList;
string FileName; //We need to know where we're putting things...
public:
WeatherStationList() { FileName = "GreenStation"; } //Default constructor...
WeatherStationList(string FName) { FileName = FName; } //The initializing constructor lets you set a different file name..
//The file related actions...
void SetFileName (string FName) { FileName = FName; } //This lets you change the name while it runs...
void WriteToFile();
void ReadFromFile();
//The traditional actions...
void AddStations();
void PostTemperature();
void PostPollenCount();
void PostAirQuality();
void Report();
void Remove(string);
void Show();
};
void WeatherStationList::AddStations()
{
string Name, Agent;
WeatherStation TemporaryBuffer;
cout << "Enter Station Information Below, Stop To Quit" << endl;
while(true) {
cout << "Weather Station Designaton: ";
getline(cin, Name);
if(Name == "Stop")
break;
cout << "Contact Person: ";
getline(cin, Agent);
if(Agent == "Stop")
break;
TemporaryBuffer.SetDesignation(Name);
TemporaryBuffer.SetAgent(Agent);
List.push_back(TemporaryBuffer);
}
}
//Remove() erases a specified object from the vector...
void WeatherStationList::Remove(string ID)
{
//Use an iterator to move through the list in order...
for(ThroughTheList = List.begin() ; ThroughTheList < List.end() ; ThroughTheList++)
if( ID == ThroughTheList->GetAgent()) { //If there's a match...
List.erase(ThroughTheList); //Remove it..
return;
}
cout << ID << " Not Found " << endl;
}
void WeatherStationList::PostTemperature()
{
int K;
double Temperature;
cout << "Enter Temperatures Below" << endl;
for(K = 0 ; K < List.size() ; K++) {
cout << List[K].GetDesignation() << ": ";
cin >> Temperature;
List[K].SetTemperature(Temperature);
}
}
void WeatherStationList::PostPollenCount()
{
double PollenCount;
int K;
cout << "Pollen count Below" << endl;
for(K = 0 ; K < List.size() ; K++) {
cout << List[K].GetDesignation() << ": ";
cin >> PollenCount;
List[K].SetPCount(PollenCount);
}
}
void WeatherStationList::PostAirQuality()
{
double AirQualityScore;
int K;
cout << "Air Quality Score count Below" << endl;
for(K = 0 ; K < List.size() ; K++) {
cout << List[K].GetDesignation() << ": ";
cin >> AirQualityScore;
List[K].SetAQScore(AirQualityScore);
}
}
void WeatherStationList::Report()
{
int K;
for(K = 0 ; K < List.size() ; K++)
List[K].Displayer();
}
int main()
{
WeatherStationList Norcal;
Norcal.AddStations();
Norcal.PostTemperature();
Norcal.PostPollenCount();
Norcal.PostAirQuality();
Norcal.Report();
}
void WeatherStationList::Show()
{
cout << "========================================" << endl;
for(ThroughTheList = List.begin() ; ThroughTheList < List.end() ; ThroughTheList++)
ThroughTheList->Displayer();
cout << "========================================" << endl;
}
void WeatherStationList::WriteToFile()
{
fstream OutFile(FileName.c_str(), ios::out);
for(ThroughTheList = List.begin() ; ThroughTheList < List.end() ; ThroughTheList++)
OutFile << ThroughTheList->GetName() << endl;
OutFile << ThroughTheList->GetAgent() << endl;
}
OutFile.close();
}
void WeatherStationList::ReadFromFile()
{
fstream InFile(FileName.c_str(), ios::in);
string Name, Agent;
ShortName Buffer;
while( true ) {
getline(InFile, Name);
getline(InFile, Agent);
Buffer.SetFirst(Name);
Buffer.SetLast(Agent);
if(InFile.eof())
break;
List.push_back(Buffer);
}
InFile.close();
}
void Menu();
int main()
{
VectorList Collection;
string Command;
while(true) {
Menu();
cout << "Command: ";
getline(cin, Command);
if(Command == "Quit")
break;
else if(Command == "Station")
Collection.AddStations();
else if(Command == "Contact Person")
Collection.AgentName();
else if(Command == "Current Temperature")
Collection.PostTemperature();
else if(Command == "Current Pollen Count")
Collection.PostPollenCount();
else if(Command == "Current Air Quality")
Collection.PostAirQuality();
else if(Command == "Show")
Collection.Show();
else if(Command == "Set") {
cout << "Enter File Name: ";
getline(cin,File);
Collection.SetFileName(File);
}
else if(Command == "Write")
Collection.WriteToFile();
else if(Command == "Read")
Collection.ReadFromFile();
}
cout << "Another product from EnviroMeasurementGreenStation" << endl;
}
void Menu()
{
cout << "--------------------------------------" << endl;
cout << " Station:\t " << endl;
cout << " Contact Person:\t " << endl;
cout << " Current Temperature:\t " << endl;
cout << " Current Pollen Count:\t " << endl;
cout << " Current Air Quality:\t " << endl;
cout << " Show:\t" << endl;
cout << " Set:\t " << endl;
cout << " Write:\t " << endl;
cout << " Read:\t " << endl;
cout << " Quit:\t " << endl;
cout << "--------------------------------------" << endl;
system("pause");
}
So, when I compile it, it shows me about 5 errors. And, here are some of those errors; class WeatherStation' has no member named 'GetName' , expected constructor, destructor, or type conversion before '.' token.
Once again, any help will be greatly appreciated.