Loop repeating program | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Loop repeating program

i did a loop with a condition to keep repeating my program after answering by a char Y or N and but when the program is repeated it starts with the first data which was in the constructor not the new that I've added to so i 'm asking how can i repeat the program with the data that has been changed

19th Jul 2017, 3:41 PM
Mohamed elqandili
Mohamed elqandili - avatar
3 Answers
+ 1
If you have constructor in your loop then you always reset your data. Costructor should be before your loop. You can post your code.
19th Jul 2017, 4:35 PM
Pavel Václavík
Pavel Václavík - avatar
+ 4
Make sure the scope of your variables is in check. Check whether or not you're redefining or reinitialising your variables inside your loop.
19th Jul 2017, 4:51 PM
Garikai
Garikai - avatar
+ 1
yes exactly well, i solved the problem all i had to do is to instantiate my object outside the loop thank you guys
23rd Jul 2017, 12:11 AM
Mohamed elqandili
Mohamed elqandili - avatar