I am creating a program that takes into account pay from a job. I will try to describe the problem I am having using some psuedo code - so dont take syntax too seriously.
I created a structure that has some of the following values:
Name as String
Amount as Double
FrequencyType as MyEnumerator
MyEnumerator looks like this:
EveryTwoWeeks = 1
TwiceAMonth = 2
Weekly = 3
Now my problem is how do I add the date ranges into my structure?
If your pay is weekly or twice a week, then I just need a single date because all other paydays should increment in 1 or 2 week blocks. But if the pay is twice a month I need two dates.
It seems like there has got to be a better way then just having two dates in my structure and knowing that you just need the 2nd date if the FrequencyType is = 2 (TwiceAMonth).
I was thinking that instead of a Structure I should use a class and then I could create a function that returns the date or dates depending on the enumeration type that you pass into it.
What would be the "correct" way of doing this? I think I need a type of enumerator that allows for more then just integer type values. Then I could do something like:
Weekly = WeeklyStructure
TwiceAWeek = TwiceAWeekStructure
TwiceAMonth = TwiceAMonthStructure
WeeklyStructure
Name as String
StartingDate as Date
TwiceAMonthStructure
Name as String
FirstDate as Date
SecondDate as Date
I dunno though, I am having a hard time figuring this out in my head. As you can see I am not the best programmer, especially when my ADD meds wear off. I can't get more then 2 steps into a problem before I lose track in my head.
I created a structure that has some of the following values:
Name as String
Amount as Double
FrequencyType as MyEnumerator
MyEnumerator looks like this:
EveryTwoWeeks = 1
TwiceAMonth = 2
Weekly = 3
Now my problem is how do I add the date ranges into my structure?
If your pay is weekly or twice a week, then I just need a single date because all other paydays should increment in 1 or 2 week blocks. But if the pay is twice a month I need two dates.
It seems like there has got to be a better way then just having two dates in my structure and knowing that you just need the 2nd date if the FrequencyType is = 2 (TwiceAMonth).
I was thinking that instead of a Structure I should use a class and then I could create a function that returns the date or dates depending on the enumeration type that you pass into it.
What would be the "correct" way of doing this? I think I need a type of enumerator that allows for more then just integer type values. Then I could do something like:
Weekly = WeeklyStructure
TwiceAWeek = TwiceAWeekStructure
TwiceAMonth = TwiceAMonthStructure
WeeklyStructure
Name as String
StartingDate as Date
TwiceAMonthStructure
Name as String
FirstDate as Date
SecondDate as Date
I dunno though, I am having a hard time figuring this out in my head. As you can see I am not the best programmer, especially when my ADD meds wear off. I can't get more then 2 steps into a problem before I lose track in my head.
Last edited: