sai rama krishna wrote:
If i want below output as ascending order from first to second row to third row etc as below how to modify the code
Well, obviously, you need to sort the input first. Since this is likely a homework assignment, or following up a homework assignment for learning purposes -- what have you done so far to modify it?
sai rama krishna wrote:
Since this is likely a homework assignment, or following up a homework assignment
this is not. you assumption is wrong
The impetus of the assumption is that you are doing this to learn. Hence, my question of asking what have you done so far.
Now surely, this is not wrong?
Why not post something which you wrote yourself that actually works.
i posted more than 50 comments with whatever i can. I do not know something that actually works. If i know would not have posted this question here. can you please provide solution. I am almost about to give up on this challenge
Start by indenting it correctly.
sai rama krishna wrote:. . . how to improve/modify my code. please advise
Remove all those commented‑out lines.
Remove all those blank lines.
Change the main method to its ideal length: one statement.
Try some object‑oriented programming: you should be able to write
and get a diamond printed. (Or maybe only a pyramid).
What do the loops on lines 42‑49 mean? Why are you using <= rather than <?
Is that enough to get you started.
Don't be lazy. You have around 25 effective lines of code. At this stage probably better would be not to use Eclipse at all, but rather have some text editor and console next to you, so you could compile and run the code from there.
sai rama krishna wrote:why eclipse wont remove blank lines when i say control A then Control Shift F to format?
i feel it is too much for a simple class
i wonder who (client) and where CashRegisterLauncher getting called?
1. Why does your print() method return an array of integers which the main() method doesn't even use? What's the point and the logic of doing that?
2. Something like PyramidPrinter would probably be a more suitable name for your class. Class names should be nouns or noun phrases.
3. Your print() method still has too many lines and has the details for doing way too many things. If a method is going to have detailed implementation in it, let it be for just one simple and focused task. If it does many different things, the method would be better written as a Composed method.
3. Your print() method still has too many lines and has the details for doing way too many things.
if i do away to multiple methods later on orchestration becoming difficult to me. can you please show exactly what you mean by this with working code as i already solved this challenge?
Have you read what Junilu wrote 2 posts ago? I really believed you'll absorb that information. Basically how I understood what he said, that you should take very small steps at a time and make some methods, so each of them would do very concrete singular task.
same thing i am trying in last 100 coments. I finally got solution. But now i do not know how to modify my code to look more like object oriented code with bunch of methods as i do not know how to interact printing spaces and printing numbers methods both similtaneously to print the pyramid structure i am interested?
I'll demonstrate to you my process. Keep in mind that there are many ways you can solve this problem. The one I first came up with many posts ago was not even object-oriented; I had all static methods. The reason I did that was because this was only one class and there didn't seem to be a compelling reason for me to create an OO design when there was just one class involved and the process was pretty much sequential. On the other hand, it might be educational to try to do it with a proper object instead of just a bunch of static methods. So, I step through an entirely new solution, using proper objects.
First of all, I see no need to convert to integers as you have been doing. The input is a String and the user is expected to include only digits so I'll make the assumption that that is exactly what the user will do.
So, the first cut will be:
I'll compile this to make sure I have no errors so far. I see that it compiles with no errors, so I continue.
Edit: The code posted above actually does have an error but it's a pretty quick fix. I'll leave it as originally posted anyway.
Now, I need a way to verify that I've done the right thing. Normally, I'd write a unit test but this time, I'll just eyeball the result by printing out the characters. I'll add a call to a method that will display something, then add that method:
I see that there are no compiler errors so I run the program and eyeball the result. My run looks looks something like this:
Enter a sequence of digits, no spaces: 3402
Ok, now I've made a little bit of progress. That's good.
Now I won't have to type in anything and I'll have the same data to work with while I fill out the program.
I run the program again to make sure I didn't mess anything up. It still runs fine.
No matter how many women are assigned to the project, a pregnancy takes nine months. Much longer than this tiny ad:
The WEB SERVICES and JAX-RS Coursehttps://coderanch.com/t/690789/WEB-SERVICES-JAX-RS