Oct 14, 2013 at 6:42am UTC
Need people to tell me where is wrong with this project. keep getting errors
LocationData.h
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
class LocationData
{
private:
string sunType;
int noOfEarthLikePlanets;
int noOfEarthLikeMoons;
float aveParticulateDensity;
float avePlasmaDensity;
float computeCivIndex;
public:
LocationData();
LocationData(string, int, int, float, float);
string getsunType();
void setsunType(string new_sunType);
int getnoOfEarthLikePlanets();
void setnoOfEarthLikePlanets(int );
int getnoOfEarthLikeMoons();
void setnoOfEarthLikeMoons(int );
float getaveParticulateDensity();
void setaveParticulateDensity(float );
float getavePlasmaDensity();
void setavePlasmaDensity(float );
float getcomputeCivicIndex();
void setcomputeCivicIndex(float );
void toString();
float civIndex(string , int , int , float , float );
};
LocationData.cpp
#include <iostream>
#include <string>
#include "LocationData.h"
using namespace std;
LocationData::LocationData()
{
sunType = "";
noOfEarthLikePlanets = 0;
noOfEarthLikeMoons = 0;
aveParticulateDensity = 0;
avePlasmaDensity = 0;
}
LocationData::LocationData(string newsunType, int newnoOfEarthLikePlanets, int newnoOfEarthLikeMoons, float newaveParticulateDensity, float newavePlasmaDensity)
{
sunType= newsunType;
noOfEarthLikePlanets = newnoOfEarthLikePlanets;
noOfEarthLikeMoons = newnoOfEarthLikeMoons;
aveParticulateDensity = newaveParticulateDensity;
avePlasmaDensity = newavePlasmaDensity;
}
string LocationData::getsunType()
{
return sunType;
}
void LocationData::setsunType(string new_sunType)
{
sunType = new_sunType;
}
int LocationData::getnoOfEarthLikePlanets()
{
return noOfEarthLikePlanets;
}
void LocationData::setnoOfEarthLikePlanets(int new_noOfEarthLikePlanets)
{
noOfEarthLikePlanets = new_noOfEarthLikePlanets;
}
int LocationData::getnoOfEarthLikeMoons()
{
return noOfEarthLikeMoons;
}
void LocationData::setnoOfEarthLikeMoons(int new_noOfEarthLikeMoons)
{
noOfEarthLikeMoons = new_noOfEarthLikeMoons;
}
float LocationData::getaveParticulateDensity()
{
return aveParticulateDensity;
}
void LocationData::setaveParticulateDensity(float new_aveParticulateDensity)
{
aveParticulateDensity = new_aveParticulateDensity;
}
float LocationData::getavePlasmaDensity()
{
return avePlasmaDensity;
}
void LocationData::setavePlasmaDensity(float new_avePlasmaDensity)
{
avePlasmaDensity = new_avePlasmaDensity;
}
void LocationData::toString()
{
cout<<"The suntype is "<<sunType<<endl<<
"The no of Earth-like Planets is "<<noOfEarthLikePlanets<<endl<<
"The no of Earth-like Moons is "<<noOfEarthLikeMoons<<endl<<
"The average Particulate Density is "<<aveParticulateDensity<<endl<<
"The average Plasma Density is "<<avePlasmaDensity<<endl;
}
float LocationData::computeCivIndex(string sunType, int noOfEarthLikePlanets, int noOfEarthLikeMoons, float aveParticulateDensity, float avePlasmaDensity)
{
float sunTypePercent;
float civIndex;
if (sunType == "O" || sunType == "o") sunTypePercent = 30;
if (sunType == "B" || sunType == "b") sunTypePercent = 45;
if (sunType == "A" || sunType == "a") sunTypePercent = 60;
if (sunType == "F" || sunType == "f") sunTypePercent = 75;
if (sunType == "G" || sunType == "g") sunTypePercent = 90;
if (sunType == "K" || sunType == "k") sunTypePercent = 80;
if (sunType == "M" || sunType == "m") sunTypePercent = 70;
civIndex = ((sunTypePercent / 100) - (aveParticulateDensity + avePlasmaDensity) / 200) * (noOfEarthLikePlanets + noOfEarthLikeMoons);
return civIndex;
}
MissionPlan.h
#include <iostream>
#include <string>
#include "PointTwoD.h"
using namespace std;
class MissionPlan
{
public:
MissionPlan();
float computeCivIndex(string, int, int, float, float);
void showDistance();
void mainMenu();
void showEntry();
int x;
float ci;
int y;
int counter;
float distance;
string sunType;
int noOfEarthLikePlanets, noOfEarthLikeMoons;
float aveParticulateDensity, avePlasmaDensity;
PointTwoD dataStore[100];
PointTwoD getData;
float computeCivIndex(ci);
void computeCivIndex(float);
//cout<<"Please select your choice :";
//cin>>choice;
};
MissionPlan.cpp
#include <iostream>
#include <string>
#include "MissionPlan.h"
using namespace std;
float MissionPlan::computeCivIndex(string sunType, int noOfEarthLikePlanets,int noOfEarthLikeMoons, float aveParticulateDensity, float avePlasmaDensity)
{
if(sunType == "Type O")
ci = (30/100)-(aveParticulateDensity + avePlasmaDensity)/200*(noOfEarthLikePlanet + noOfEarthLikeMoons);
else if(sunType == "Type B")
ci = ((45/100)-(aveParticulateDensity + avePlasmaDensity)/200)*(noOfEarthLikePlanets + noOfEarthLikeMoons);
else if(sunType == "Type A"
ci = ((60/100)-(aveParticulateDensity + avePlasmaDensity)/200)*(noOfEarthLikePlanets + noOfEarthLikeMoons);
else if(sunType == "Type F")
ci = ((75/100)-(aveParticulateDensity + avePlasmaDensity)/200)*(noOfEarthLikePlanets + noOfEarthLikeMoons)
else if(sunType == "Type G")
ci = ((90/100)-(aveParticulateDensity + avePlasmaDensity)/200)*(noOfEarthLikePlanets + noOfEarthLikeMoons);
else if(sunType == "Type K")
ci = ((80/100)-(aveParticulateDensity + avePlasmaDensity)/200)*(noOfEarthLikePlanets + noOfEarthLikeMoons);
else if(sunType == "Type M")
ci = ((70/100)-(aveParticulateDensity + avePlasmaDensity)/200)*(noOfEarthLikePlanets + noOfEarthLikeMoons);
else
cout<<"Error! No such type!!"<<endl;
return computeCivIndex;
}
void MissionPlan::showDistance()
{
distance = sqrt(((x*x) + (y*y))*100);
cout << "Total (approx) travel distance = ";
cout << distance <<" million km"<< endl;
}
PointTwoD.h
#include <iostream>
#include <string>
#include "LocationData.h"
using namespace std;
class PointTwoD
{
private:
int x;
int y;
LocationData locationData;
public:
float civIndex;
PointTwoD();
PointTwoD(int new_x, int new_y, LocationData new_locationData, float new_civIndex);
int getx();
void setx(int new_x);
int gety();
void sety(int new_y);
string getsunType();
void setsunType(string new_sunType);
int getnoOfEarthLikePlanets();
void setnoOfEarthLikePlanets(int new_noOfEarthLikePlanets);
int getnoOfEarthLikeMoons();
void setnoOfEarthLikeMoons(int new_noOfEarthLikeMoons);
float getaveParticulateDensity();
void setaveParticulateDensity(float new_aveParticulateDensity);
float getavePlasmaDensity();
void setavePlasmaDensity(float new_aveParticulateDensity);
//float getcomputeCivicIndex();
//void setcomputeCivicIndex(string, int, int, float, float);
LocationData getlocationData();
void setlocationData(LocationData new_locationData);
float getcivIndex(void);
void setxy(int new_x,int new_y);
void setcivIndex(float new_civIndex);
void toString();
//static float computeCivicIndex;
};
PointTwoD.cpp
#include <iostream>
#include <string>
#include "PointTwoD.h"
using namespace std;
PointTwoD::PointTwoD()
{
x = 0;
y = 0;
LocationData locationData();
civIndex = 0;
}
PointTwoD::PointTwoD(int new_x, int new_y, LocationData new_locationData, float new_civIndex)
{
x = new_x;
y = new_y;
locationData = new_locationData;
civIndex = new_civIndex;
}
int PointTwoD::getx()
{
return x;
}
void PointTwoD::setx(int new_x)
{
x = new_x;
}
int PointTwoD::gety()
{
return y;
}
void PointTwoD::sety(int new_y)
{
y = new_y;
}
void PointTwoD::setxy(int new_x,int new_y)
{
x=new_x;
y=new_y;
}
LocationData PointTwoD::getlocationData()
{
return locationData;
}
void PointTwoD::setlocationData(LocationData new_locationData)
{
locationData = new_locationData;
}
float PointTwoD::getcivIndex()
{
return civIndex;
}
void PointTwoD::setcivIndex(float new_civIndex)
{
civIndex = new_civIndex;
}
void PointTwoD::toString()
{
cout<<"Civ Idx : "<<civIndex<<" at sector ("<<x<<","<<y<<")"<<endl;
}
Oct 14, 2013 at 8:10am UTC
5 C:\Users\User\Desktop\New proj\ASSIGN 1\main.cpp In file included from main.cpp
32 C:\Users\User\Desktop\New proj\ASSIGN 1\MissionPlan.h expected `;' before '(' token
C:\Users\User\Desktop\New proj\ASSIGN 1\main.cpp In constructor `MissionPlan::MissionPlan()':
58 C:\Users\User\Desktop\New proj\ASSIGN 1\main.cpp insufficient contextual information to determine type
114 C:\Users\User\Desktop\New proj\ASSIGN 1\main.cpp no matching function for call to `getline(std::istream&, <unknown type>)'
Oct 14, 2013 at 8:24am UTC
float computeCivIndex(ci);
'ci' is not a typename.
Use of code tags is strongly recommended.