can anyone help me convert this code from array to Vector?
I need this in it
class VectorList {
vector<WeatherStation> List;
vector<WeatherStation>::iterator ThroughTheList;
public:
VectorList() {;}
#include <iostream>
#include <string>
using namespace std;
class WeatherStation
{
string StationDesignation; //Identifies the station
string StationAgent; //Who's responsible
double Temperature; //The temperature
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 Show()
{
cout << StationDesignation << endl;
cout << StationAgent << endl;
}
};
//Functions
void Menu();
int AddStation(WeatherStation[],int);
void PostTemperatures(WeatherStation*, int);
void DailyReport(WeatherStation*, int);
void HighLow(WeatherStation*, int);
int main()
{
string Command;
WeatherStation names[25];
int Size = 0;
while (true){
Menu();
cout << "Enter Command: " ;
getline (cin,Command);
cout << endl;
cout << endl;
if (Command == "Quit")
break;
else if (Command == "Add Stations")
Size = Size + AddStation(names,25);
else if (Command == "Post Temperatures")
PostTemperatures (names,Size);
else if (Command == "Daily Report")
DailyReport (names, Size);
else if (Command == "High-Low Report")
HighLow (names, Size);
}
}
int AddStation(WeatherStation List[], int MaxSize) //Add Stations & Agent
{
string ID, Agent;
int K;
cout << "Enter Station Information Below, Stop to Quit" << endl;
for (K=0 ; K<MaxSize ; K++) {
cout << "Enter Weather Station Designation: " ;
getline(cin, ID);
if (ID == "Stop")
break;
cout << "Enter Contact Person: " ;
getline(cin,Agent);
if (Agent == "Stop")
break;
List[K].SetDesignation(ID);
List[K].SetAgent(Agent);
}
return K;
}
void Menu() //The Menu
{
cout << "=========== Menu ===========" << endl;
cout << "==== Choices: ==============" << endl;
cout << "Add Stations" << endl;
cout << "Post Temperatures" << endl;
cout << "Daily Report" << endl;
cout << "High-Low Report" << endl;
cout << "Quit" << endl;
cout << "==============================" << endl;
cout << endl;
}
void PostTemperatures(WeatherStation* List, int Size) //Post Temperatures
{
int K;
int Degree;
cout << "Enter Reported Temperatures.." << endl;
for (K=0 ; K<Size ; K++){
List[K].Show();
cout << "Enter Temperature: ";
cin>>Degree;
List[K].SetTemperature(Degree);
}
}
void DailyReport (WeatherStation* List, int Size) //Daily report
{
int K;
double Sum=0;
double CelSum;
double CelDegrees [25];
cout << "==========NGS Daily Temperature Report==========" << endl;
cout << "================================================" << endl;
cout << "------------------------------------------------" << endl;
for (K=0 ; K<Size ; K++){
CelDegrees[K]=(5 *(List[K].GetTemperature() - 32))/9; //Finding the Celsius
CelSum=(5 *(Sum - 32))/9; //Finding the Mean Celsius
cout << List[K].GetDesignation() << " : " << List[K].GetTemperature() << "\370F " << CelDegrees[K] << "\370C" << endl;
cout << "------------------------------------------------" << endl;
Sum=Sum+List[K].GetTemperature(); //Getting the Sum of all temperatures
}
cout << "Mean : " << (Sum/Size) << "\370F " << (CelSum/Size) <<"\370C" << endl;
cout << "================================================" << endl;
}
void HighLow(WeatherStation* List, int Size) //High-Low
{
int K;
double Max=List[0].GetTemperature();
double Min=List[0].GetTemperature();
double MinCelDegrees=0, MaxCelDegrees=0;
for (K=0 ; K < Size ; K++){
if(List[K].GetTemperature() > Max) { //Finding Max
Max=List[K].GetTemperature();
MaxCelDegrees=(5 *(Max - 32))/9; //Finding Max Celsius
}
if(List[K].GetTemperature() < Min){ //Finding Min
Min=List[K].GetTemperature();
MinCelDegrees=(5 *(Min - 32))/9; //Finding Min Celsius
}
}
cout << "========NGS Temperature Data Report========" << endl;
cout << "-------------------------------------------" << endl;
cout << "Lowest Temperature: " << Min << "\370F " << MinCelDegrees << "\370C" << endl;
cout << "-------------------------------------------" << endl;
cout << "Highest Temperature: " << Max << "\370F " << MaxCelDegrees << "\370C" << endl;
cout << "-------------------------------------------" << endl;
cout << "========End Temperature Data Report========" << endl;
}