1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
|
#include <iostream>
#include "CarbonFootPrint.h"
#include "Building.h"
#include "Car.h"
#include "Bicycle.h"
#include "Plane.h"
#include "vector"
#include "string"
using namespace std;
int main()
{
int n =0;
cout <<"Enter ammount of objects you would like to get the carbon foot print of. " << endl;
cin >> n;
CarbonFootPrint *list[n];
char type;
for (int x = 0; x < n; x++)
{
cout << "\nPlease select an object type (1)Building (2)Car (3)Bicycle (4)Plane: ";
cin >> type;
switch (type)
{
case '1':
{
string name;
cout << "Enter Building Name: ";
cin.ignore(1000, '\n');
getline(cin,name);
double electric;
cout << "Enter Amount of Electric used for the building(kilowatts): ";
cin >> electric;
double gas;
cout << "Enter Amount of gas used for the building(Enter in 1000 BTU's): ";
cin >> gas;
list[x] = new Building(name, electric, gas);
break;
}
case '2':
{
string Carname;
cout << "Enter Car Name: ";
cin.ignore(1000, '\n');
getline(cin,Carname);
double Miles;
cout << "Enter Amount of Miles driven: ";
cin >> Miles;
double Mpg;
cout << "Enter Fuel efficiencity(MPG): ";
cin >> Mpg;
list[x] = new Car(Carname, Miles, Mpg);
break;
}
case '3':
{
string Bikename;
cout << "Enter Bicycle Name: " ;
cin.ignore(1000, '\n');
getline(cin,Bikename);
list[x] = new Bicycle(Bikename);
break;
}
case '4':
{
string Planename;
cout << "Enter Airline: ";
cin.ignore(1000, '\n');
getline(cin,Planename);
double FlyMiles;
cout << "Enter Amount of Miles flown: ";
cin >> FlyMiles;
list[x] = new Plane(Planename,FlyMiles);
break;
}
}
}
for (int i = 0; i < n; i++)
{
cout << "\nObjects Name: ";
list[i]->print();
cout << " [Carbon foot print] : " << list[i]->getCarbonFP() << endl;
}
cout << endl;
system("PAUSE");
}
|