All things are lawful, but not all things are profitable.
Ben Poland wrote:In my head this seems like it would be quite a complex idea to write. So, here's the break down of what I want it to do:
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Ben Poland wrote:Winston, I actually wrote up what I want it to do before I opened NetBeans
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
However, since you're designing what looks like a GUI, I think I'd be writing diagrams of what I want each screen (or box) to look like, including any buttons or scrollbars, with maybe a bit of narrative describing the flow. They don't need to be works of art, but they should give you some "visual" clues.
Also, this description "Ask user in words, what is the value of a specific point in the number generated (123456: Position 3 = Three thousand)" seems a bit vague.
What are you trying to test? That a user can count up to 3, or correctly translate the word "third"? Seems like an awful lot of code for such a basic test.
Is it always going to be 3? Do you specifically want to see the word "third" or "ninth" - ie, an English 'ordinal' - rather than "position 3"? If so, you need to translate a number to an ordinal word...for no good reason I can see (except maybe for the mental exercise).
Ben Poland wrote:The idea is for this to be used to teach place values, so for a kid to see the number in digits and respond with words for the place values.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
All things are lawful, but not all things are profitable.
Ben Poland wrote:I obviously need it to not be in reverse and I don't know how to now put this into an array which I think would be the best way to setup the actual place value questions. Hope that makes sense.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
There are several ways of doing this, but you might want to have a look at String.toCharArray().
After all, do your "digits" actually have to be numbers? You're going to be comparing them to something the user entered from the keyboard, don't forget,
Also: An ArrayList (or indeed any type of Java collection) should always be declared with a type, ie:
ArrayList<SomeType> splitVal = new ArrayList<>();
not:
ArrayList splitVal = new ArrayList();
and even better is to declare it as a List, viz:
List<SomeType> splitVal = new ArrayList<>();
That way, if you decide later on that another type of List (eg, a LinkedList) is better, you only have to change your code in one place.
All things are lawful, but not all things are profitable.
Ben Poland wrote:So, next question, I figured the best way to make this work next is to have one of the digits printed out as bold or highlighted, otherwise I may get the same number twice and there won't be a frame of reference to which one the question refers to.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Ben Poland wrote:What is the advantage of using List<>name = ArrayList rather than ArrayList<> name = ArrayList? Aside having a only single piece of code to change(always an advantage) is there a functional difference?
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Ben Poland wrote:1) Display random value: 12345
Really what it boils down to is getting this to work in the simplest way. In theory it's very straight forward, but seems in practice not so much... I hope that makes more sense this time :/
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
You check the length of string "12345" and you generate random place value which is between 1 and the string length (including).Ben Poland wrote:can't ask for place value 6 if the random number is only 12345.
Knute Snortum wrote:What you probably want to do is split the number digit by digit from right to left, assigning the next power of 10:
5 * 10^0
4 * 10^1
3 * 10^2
etc.
So, to split the number into digits, can you think of a way to do this with the mod (%) operator and integer division?
All things are lawful, but not all things are profitable.
Ben Poland wrote:Yes, the thing I'm trying to figure out now before even assigning the place value is how to NOT have a duplicate number in the string... If it's 6 numbers in length, I need it not to print out 463542 for example as if the question is "What is the place value of 4?" the user will have no clue which 4 is meant.
All things are lawful, but not all things are profitable.
All things are lawful, but not all things are profitable.
You guys haven't done this much, have ya? I suggest you study this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|