i | #spaces | total |
---|---|---|
0 | 3 | 3 |
1 | 2 | 3 |
2 | 1 | 3 |
3 | 0 | 3 |
i | #spaces | total |
---|---|---|
0 | 4 | 4 |
1 | 3 | 4 |
2 | 2 | 4 |
3 | 1 | 4 |
4 | 0 | 4 |
i | #digits |
---|---|
0 | 1 |
1 | 2 |
2 | 3 |
3 | 4 |
sai rama krishna wrote: But how to get pyramid structure ... that is where all the complexity using multiple methods using OOP and OOD principles?
Whatever complexity there was, it was all in your head. If you had emptied your mind and put your thoughts down on paper like we have suggested to you all along, it would have been much easier for you to untangle the string of ideas you had tied into a Gordian Knot in your brain.
There's practically no OOP or OOD involved in solving this problem. It's all pattern analysis and recognition, really. Combine that with some discipline and a step-wise approach, not trying to solve everything all at once but making one small step forward instead, and then refining/adding to your solution. If you do that, you'll eventually get to where you need to get. Small, sure steps forward are the key to success. And always running your program to verify that you haven't messed up anything before you try to make the next small step forward.
sai rama krishna wrote:i will try to remember this valuable advise and hope not fall in to that gordian mind loop you mentioned
public class PyramidPrinter {
public static void main(String[] args) {
PyramidPrinter printer = new PyramidPrinter();
printer.print(getUserInput());
}
private static final Scanner input = new Scanner();
private static String getUserInput() {
System.out.print("Enter a sequence of digits, no spaces: ");
return input.nextLine();
}
private void print(String sequence) {
}
}
I'll compile this to make sure I have no errors so far. I see that it compiles with no errors, so I continue.
sai rama krishna wrote:
for me above code gives below error
The constructor Scanner() is undefined
please advise.
sai rama krishna wrote:
I think i missed important connection as above
when i run above code console shows
Enter a sequence of digits, no spaces:
then when i try to enter not displaying and not doing anything with entered number?
DO NOT POST MY SOLUTION CODE!!!
sai rama krishna wrote:I forget to include sort method
Arrays.sort(digits); withing print method in my last output. After putting it i got it sorted as well correctly
Daniel Andres wrote:Are you learning Java on your own then? Have you ever taken a programming class? If not, then it's not impossible to learn but jeez that would be very hard in my opinion. Unless you are James gosling perhaps
sai rama krishna wrote:I am having masters from non IT non computer back ground. Lot of simple things to you guys looks strange to me unless i read them few times and practice
All things are lawful, but not all things are profitable.