objectname->getEvents('index of event's list')->getSection()
Probably more like:
objectname.Events.get('index of event's list').Section
That assumes that :
'objectname' is the name of an object (not a pointer to the object).
The linked list of events is public and named 'Events'.
The section information is a public member variable of the event object named 'Section'.
This will probably crash if the index is not in the list because get() will return false (0) which is not a valid object.
"->" this should point to memory adress, does not it?
That operator is the pointer dereference operator. Pointers are stored in memory, and point to other locations in memory. So, the technical answer to your question is yes. But the question does not make sense.
The objectname thing is an instance of a class. There are instances and objects. instances are pointers. objects are not. So, the thing on the left of the -> operator is an instance, not an object, so objectname is wrong. It should be instancename. Events is an object in the class. Why it has a plural name is a mystery. The Events object has a get() method that takes some argument. The actual value of that argument is not the single character 'index of event's list'.
So, it's really time that you started asking your questions properly.
Events is an object in the class. Why it has a plural name is a mystery.
Well to the program itself Events is an object, since I'm trying to acess it from an instance as you suggested. However Events was declared as a list by me
The Events object has a get() method that takes some argument. The actual value of that argument is not the single character 'index of event's list'.
The idea is to get that value using the method, as I asked in my first message getEvents would be the method. Since I want that value in a specific location, how should I proceed? I would aprecciate a generic model.
Which instance of the Events (I hate that name) class (class names should almost always be singular; you don't have an instance of the Dogs class do you?) do you want to get the data for?
Regardless, you have to somehow define which item in the events list you want. Then, you need to walk the linked list until you find that item, then return the data for that item. Whether you want the data in the 3rd item in the list or the data for the event on Tuesday the 13th of December at 4:00 PM determines how you decide that you have located the correct item. It has nothing to do with the fact that you need to walk the list, or how you return the item's data.
PaulS:
No, Events is NOT a list. events is a list.
events is a list of Events. That is wrong. events should be a list of Event instances.
Buddy, this is just what is exposed, red blocks are the instances and events is the list. Still can't understand why you keep exposing this. Again, how can I tell my program that I want to acess the value of Event instance ? And how can I tell the program its the red right block instead of the red left block? Do you understand me?
I asked for a generic synthax model. I'll consider you haven't read it among all the messages I sent in this topic.
PaulS, I want for example, to acess Section event instace, and it should be from the right red block (consider right block with higher index).I'm on my knees in my office at this very moment, hoping you to understand me.
Ignoring for the moment that you have provided no proof that you have written any code, and tried to make up crap as you've encountered requests for clarification, your question still does not make sense.
I will assume that you have an Event class. I will assume that you have a list, events, that contains instance of the Event class. I will assume that you have an instance of a Schedule class, called whereJoesSupposedToBeWhen.
Now, you keep harping on getting something called Section, which looks to me like a class, not an instance of the class.
Lets suppose, though that Section is a member of the Event class, with some undefined type (maybe string).
Joe has an Event on Tuesday, at 3:00PM, in some Section, that last 1 hour. He has another Event in his list for Friday, at 2:30 AM, in some other Section.
Now, which Section are you looking for? The one for Joe's Event on Tuesday or the one for Joe's Event on Friday, or the one for Sally's Event on Monday?
Ignoring for the moment that you have provided no proof that you have written any code
Do I actually need to prove this ?
your question still does not make sense.
Ouch my knees hurt so bad.
I will assume that you have an Event class. I will assume that you have a list, events, that contains instance of the Event class. I will assume that you have an instance of a Schedule class, called whereJoesSupposedToBeWhen.
Your are assuming right, but whereJoesSupposedToBeWhen nah.
class Fertilizer
{
public :
void setSilo(char *s);
void setVol(float volumeFert);
char *getSilo();
float getVol();
private :
char _silo[7];
float volumeF;
};
class Events
{
public :
void setSection(int section);
void setDuration(int duration);
void setSequence(int sequence);
void setVolumeH2O(float volumeAgua);
void setPort(int port);
int getPort();
int getSection();
int getDuration();
int getSequence();
float getVolumeH2O();
void setFertilizer(LinkedList<Fertilizer*>);
LinkedList<Fertilizer*> getFertilizer();
private :
int _section;
int _port;
float _duration;
int _sequencial;
float _volumeH2O;
LinkedList<Fertilizers*> _fertilizers;
};
class Schedule
{
public:
void setDay(int day);
void setHour(int hour);
void setMinute(int minute);
void setSecond(int second);
int getDay();
int getHour();
int getMinute();
int getSecond();
void setEvents(LinkedList<Events*>);
LinkedList<Events*> getEvents();
private :
int _day;
int _hour;
int _minute;
int _second;
LinkedList<Events*> _events;
};
Lets suppose, though that Section is a member of the Event class, with some undefined type (maybe string).
No,it is int number.
Joe has an Event on Tuesday, at 3:00PM, in some Section, that last 1 hour. He has another Event in his list for Friday, at 2:30 AM, in some other Section.
Now, which Section are you looking for? The one for Joe's Event on Tuesday or the one for Joe's Event on Friday, or the one for Sally's Event on Monday?
Note that among the event instance, we have Sequence. This will determine which red block comes first (lower numbers comes first). And I also have a sort method to put all lists in order within the instance of Schedules. So this stablish indexes to everything ( See, its not a made up crap come on...). Was this thread usefull for you to understand? Do you need anything else?
The Schedule class has a linked list of Events objects called _events.
The Events class has a member called _section.
You can not get the _section member from the _events list. You need to pick a SINGLE instance from the _events list. Once you have that, you can get the _section value for that specific instance.
I still don't know which of the instances in the _events list you want the _section value for.
"Joe has an Event on Tuesday, at 3:00PM, in some Section, that last 1 hour."
Nice ! This info is represented by the image shown previously. We can have two options here, Joe is done for this day or Joe has something else to do.
If he is done, There will be another schedule for him, and he knows that "He has another Event in his list for Friday, at 2:30 AM, in some other Section".,hence "Sally's Event on Monday" must wait. Joe will do everything he must do on Friday, if one section is programmed ONE red block. Then event is closed, so is the grey block.. When Sally's event arrives, there will be another grey block and so on.
Joe has something else to do : We are still on Tuesday, at 4:00PM. We need to go for another section ( we're moving to another red block but we're still in the same schedule (grey block)), hence we are changing our index. We'll keep moving until nothing else on Tuesday must be done. Keep moving = switch among those red blocks = increasing index.
Yes yes, sadly i thought this was obvious. I meant Sally's event must wait not based on any depedency of Joe's event. It was based by TIME dependecy.
I'll try this another way.. consider "schedule" as the instance of Schedule class. I'll create examples and put the corresponding synthax to acess the values, and then confirm if its right and in negative case replace with the right answer.
I want to access Joe's section on Tuesday, at 3:00PM (consider this is first Joe's event on this day and also the first Event in the list of schedules).
schedule(0)->events(0).getSection --------- Note that i'm putting '0' indexes this would lead me to the specific location within the list.
Joe's section still on Tuesday,but later...
schedule(0)->events(1).getSection
Another Joe's section on Tuesday, even later
schedule (0)->events(2).getSection
Now we must acess another Joe's event,but this one is on another day.
Joeยดs schedule for Thurdsday (index 1 because Thursday comes after Tuesday)
schedule(1)->events(0).getSection
I'm doing this in the most ridiculous way, this is just a JSON
schedule(0)->events(0).getSection --------- Note that i'm putting '0' indexes this would lead me to the specific location within the list.
() are used to denote that you are calling a function. [] are array access operators. Your schedule object is not an array.
Your _events object (not events) is private. You have a getEvents() methods in the Schedule class which returns the complete list, but the Events class does not implement the [] operator (it could, but it currently doesn't) so you can't do ANY of what you suggest up there.
We are back to the question I have been trying to get an answer to all day. Which event? You can make getEvents() (again, this should be getEvent()) take one, two, or 127 arguments. Then, you walk the list to find the event that matches the undefined criteria.
In my head in think about indexes.
So, you want your class to have another method, with the name operator []. Yes, that IS the name. The return type will be Event *.
In the Schedule header file:
Event *operator [](int n);
Then, in the source file,
Event *Schedule::operator [](int n)
{
Event *pEvent = NULL;
// Walk the _events list to find the nth item. Assign that to pEvent
return pEvent;
}
Or, add a getEvent(int n) method that does the same thing.
Or, add a getEvent(int sequence) method that walks the list, looking for the Event with that sequence.
PaulS , you have proposed the trivial way, this obviously will work for that i'm very thankfull. However as stated in the first message of this topic I'm using this lib
Which has its own way to acess those values, I was interested of understanding this lib's synthax, understanding it better would provide me goods in the future. Ok?
I've thought about the synthax a little more and I guess I'm getting closer, I'm not able to test it at the moment that's why I'm asking for help over here. If you have the knowledge of managing this lib specifically, please consider sharing the info.
possible synthax to me right now would be : Schedules.get(0)->getEvents().get(0).getSection()
This would return me the Sector within the Events List (left red block).
Does this make sense to you ? Take a look in "Getting Started" tips of the lib,then look into "Getting Elements"