Click here to Skip to main content
15,894,405 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
THE ERRORS ARE
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="">)'

////////////////////////////////////////////////////////////////////////////////////
THE CODES

LocationData.h
C++
#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
C++
#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
C++
#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
C++
#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
C++
#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
C++
#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;

}


[edit]Code blocks added - OriginalGriff[/edit]
Posted
Updated 14-Oct-13 0:00am
v2
Comments
nv3 14-Oct-13 4:25am    
Sorry, but these are plain compiler errors. Read the error message, go to the line that is mentioned in the message and correct your mistake.
Member 10334475 14-Oct-13 4:32am    
I read it but I couldn't solve it. need help
[no name] 14-Oct-13 4:48am    
What kind of help? You must do your own assignment. Pick any error message - go to the line it comes from and try to figure out what is happening.
Thanks7872 14-Oct-13 4:53am    
First of all,you should post the smallest possible code snippet. Don't post whole code dump.

Only post the code block in which you got error (use Improve question ). Also mention what the error is and what you have tried so far.
OriginalGriff 14-Oct-13 6:02am    
I'm added the code blocks for you, but in future please try to use them.
And please, please - for your sake as well as ours - learn to indent your code! If you ask it nicely, VS will do it for you with your preferred bracketing style.

Unindented code is hard to read, and thus hard to maintain.

1 solution

Fix your MissionPlan.h.
You call executing code without being in a function of the class.
You cannot call executable code directly in the class body, you have to be in a function to do so.
See also my comment to your question.
Cheers
Andi
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900