Best way to create 3 objects

Hey, im new to Arduino and kind of new to programming. I am on internship right now where i thought i will be doing web dev, but at the end i ended up with arduino and prototyping. I've had to copy existing device. I did it.I hard coded in stupid way all of it but then i hit roadblock with editing timers of different phases. Still trying to hard code it would be extremaly stupid so i jump into tutorials about classes and objects, right now im studying it. My idea was to make class that would let me to create 3 objects. Each one with name,hour,min,sec. At first created in code. Example

Phase Aeration("Aeration", 05,00,00);
Phase Fallout("Fallout",06,00,00);

But i have one question about that approach. Would it be possible and how to edit this 3 numbers. I need to make this default at the begin but let user change it. I have prepared menu for it already. But i cant find information if objects after being created can be edited in this scenario with two buttons, one that add 05 min and second subtract 05min.

Im sorry if that question or approach is stupid. I always try not to spam various forums and do my own research but this time i am in a hurry

the OO approach is not stupid when you have multiple "instances" (samples) of the "same thing" or concept.

Take the Serial port on an Arduino Mega for example, you have 4 of them, each inheriting from the HardwareSerial class and the begin() method let you choose the baud rate or other settings to configure this particular instance.

so if you have a Phase class that has 3 instances variables that are numbers it's (almost) OK to do

Phase Aeration(“Aeration”, 05,00,00);
Phase Fallout(“Fallout”,06,00,00);

(almost because you might not know that writing 0 in front of a number means you are writing in Octal representation, base 8, so 09 does not exist for example).

That will create the instances with those default values if your constructor is storing the parameters in the instance variables. if you want to edit those later, you need to build a way for the user to decide which instance s/he is working on and have methods to update the value

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.