10-26-2017 11:26 AM
I'm a high-school student working on a project. My teacher just introduced Arrays to us and im having a hard time implementing it into our already finished vending machine program. Any specific way to go on about this?
10-26-2017 11:30 AM - edited 10-26-2017 11:33 AM
Your code does not contain any arrays, and it is not clear where the "arrays" should be used. Do you have a more specific description of what should be done?
(Still as a first step get rid of all these local variables and connect your terminals to the code instead. Did the teacher really tell you do do it as you currently do? Very bad form! Also try to use regular primitives instead of formula nodes. Did you notice that your loop spins millions of times per second consuming all CPU of one core? Unless you expect to insert millions of coins per second, slow it down!)
10-26-2017 11:46 AM - edited 10-26-2017 11:46 AM
10-26-2017 03:25 PM
Here's a quick draft how you could use integer arrays (but you need to implement it yourself!). If you can't find certain tools, ask your teacher for help. 😄
Of course there could be mistakes (unintentional or intentional :o), so verify correct operation under all conditions. Make sure to limit the inputs to non-negative integers in the control properties or somebody could make a lot of change by entering -1000 candy bars. Don't use an unsigned datatype or the subtraction might give you interesting results 😄
Use the array legends for the array element descriptions and make sure to format the output to two decimal digits padded with zeroes. Left aligned indicators and controls look better.
Be prepared to explain the purpose of every single item on the diagram or front panel to your teacher. What it does, why it is needed, what would happen if it is removed, what would be an equivalent replacement, etc.