12-10-2015 11:28 AM
Alright, so I have a program that consists of string and boolean operators, as well as a number of case structures. In this program, I pretty much ask the user various questions to identify what type of manga they would like. I added 5 genres, 5 mangas, and a synopsis for each of those manga. However, I still have to implement a for loop into this program. What I was thinking was perhaps I'd start with a case structure asking what genre the reader prefers, then continue by creating a for loop and inputing several manga for the user to read, but in a random order each time they run the program. Unfortuanetly, I am not knowledgable enough on For Loops to perform this task. Can anyone give me tips on how to accomplish this goal of mine?
File with string and boolean operators, and case structures is attached so that you have a visual interpetation of what I was talking about initially.
Solved! Go to Solution.
12-10-2015 11:38 AM
No, that's not scalable. Imagine you need to expand it to 100 question later. suddenly you have a structure pyramid the size of Egypt. 😄
Use a simple state machine and an array of questions. You can randomize the order using established algorithms. (e.g. use riffle to generate an array of indices, then reorder the array accordingly using a small FOR loop.
12-10-2015 11:53 AM
Thanks for your reply!
Two final questions...
Do you feel that my program is alright? Or do you feel it's too simple/needs more work?
Secondly, I just created a program that includes a for loop. The way it works is that you enter in the manga genre that you feel you'd like the most, then you enter in the manga genre that you'd like to get into. This is where the for loop comes in. Let's say for example that you Choose Action for the 1st question, and Adventure for the 2nd Question. The formula that is included in the for loop is 100-(Difference of the two genres) + i. The difference of the two genres would pretty much be how different they are. So if you were to transition from reading Action manga to Adventure manga, the chances of you seeing elements of an Action manga in an Adventure manga would be very high. The array for the for loop goes by the name enjoyment factor. This is because if elements in action manga and adventure manga would parallel each other, the chances of you enjoying adventure manga would be very high. However, say that your 2nd choice would be slice of life manga. The chances of elements in an action manga being included in a slice of life manga is extrememly low. So, the formula for that would be 100-(80) + i. With that, the enjoyment factor would be extrememly low. A low enjoyment factor would pretty much constitute not even giving slice of life manga a chance. Also, the i constant would be increasing because the 0,1,2,3.... of the i represents the amount of manga that you'd be reading. In this formula, reading more of a manga you want to get into= enjoying it the more you read them. I apologize if my grammer in this paragraph I've written is grade-school level. It would mean a lot if you told me what you think of both of my questions.
File for new idea is attached, not every case structure is complete, only the Action to Adventure case structure.
12-10-2015 01:04 PM - edited 12-10-2015 01:04 PM
Again, don't stack structures. Use a state machine instead. Keep information in a shift register on what question has been asked alread and what the anwers were, etc. Your FOR loop does not do anything useful. You even have duplicate string diagram constants.
Create an array of genres as items of an enum. Using user entered strings is pointless because getiing a matching case is infinitely small because any difference in spelling or capitalization would execute the default case. If the genres should be changeable at run time, use a listbox or similar.