Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
C++ Project, need all the help i can get!
#11
are you allowed to write your own header files for class definitions? or are you just working with an array of like structs or something where the struct would be:

struct LightingMode
{
char option;
int floodlightCount;
char givenOrRandom;
double floodlightDistance[floodlightCount]; //its been awhile since i worked with arrays that aren't in a class without a constructor, not sure if syntax is legal
int/double floodlightPower;
double floodlightHeight[floodlightCount];
}

//calculation functions goes here

as for putting the values in the array, after calculating the value of light in a 2d cell, store the value in that arrays cell using a double for loop. for example

double courtCells[cellHeight][cellWidth];
LightingMode first;

for(int i = 0; i < cellHeight; i++)
{
for(int j = 0; j < cellWidth; j++)
{
courtCells[i][j] = Function1(First ,Function2(first));
}
}

where function 1 is the light level(that returns a double) whose parameter is a LightMode struct and an int value(distance), which is calculated by passing the LightMode struct into Funtion2(the distance calculating function whose parameter is a struct and returns an int)

at least i think, not sure how far in your class youve gotten into in C++

using a while(fin.good()) loop or similar loop, I would input the data into the struct directly with fin(or whatever you decide to name it to the point where you get to

fin >> givenOrRandom;
where there's one if/else statement where it checks the char where its either given or random. so you must do one or the other
if(givenOrRandom == C) do something
else do the other thing

I would personally have done this in a class header file(given my current knowlege, as a constructor could easily just do all the work for you)
Reply


Messages In This Thread
C++ Project, need all the help i can get! - by Dudewitbow - 2014-05-01, 07:22 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)