I am not even close to you guys skill level, but isn't one important thing of writing code keeping it readable?
Greets,
~BSCode266
User Profile
Collapse
-
Well reverse3 isn't recursive. It is making a call to reverse1. For it to be recursive it should call itself.
A little sidenote, you really should try to avoid using variables with names like "a", "b", "c". Name them to the thing they represent just like Jos did, call it "num". Now your code is small but if you develop this as a habbit you are going to be in a...Code:return reverse1(a/10, 10*rev+a%10);
Leave a comment:
-
I think you are doing it wrong. From what i understand what is important in this excercise is the recursion. As it is the reversing of digits i think the goal is to have one method do it all.
Take a look at this simple example with a global counter. In this counter you would have to put the length of the int.
...Code:void method( int counter){ if(counter == 0){ //Spot where you return the reversed intLeave a comment:
-
Do you really want to go through the for loop 4 times? If not you could always use a break; And i don't see whats wrong with the if(i==0) if you are only going to use it once.Leave a comment:
-
Thank you very much Jos. It was the preferredSize of the panel which was obviously way to small. Because if the panel is bigger then its preferredSize it doesn't have to scroll even tho there are object outside of the screen.
Thanks alot!!!!
Kind regards,
BSCode266Leave a comment:
-
I really could use some help. Still haven't been able to find a solution for this.
Does anyone perhaps have a sample of a preferredSize method for a custom LayoutManager which would work with a JScrollPane?
Desperately in need of help,
~BSCode266Leave a comment:
-
If you want to make sure there are no letters or any other symbols I would suggest the use of a method in the Character wrapper class.
Example:
...Code://Loop just as the previous example to go through all args. for (int i = 0; i < args.length; i++) { //Temporary String to save the digits in. String temp; //Loop through a single args. for(int j = 0; j < args[i].length();Leave a comment:
-
I have done the following after your response:
This does display the upper elements of the panel but still does not scroll. I am not really that familiar with the JViewport and googling on it doesn't really give great examples....Code:JViewport viewport = new JViewport(); viewport.setSize(frameWidth, frameHeight); viewport.setView(panel); JScrollPane scroll = new JScrollPane(viewport);
Leave a comment:
-
-
BSCode266 replied to setEnabled(false) for Checkbox using jdk 1.6 - non-clickable but not grayed outin JavaThis probably is the reason it isn't greyed out. I never use AWT components, i love Swing better.Code:cb.setBackground(prompt.style.backgroundColour);
Greets.
~BSCode266Leave a comment:
-
Layoutmanagers, JScrollPane and setLayout(null)
Hey everyone,
I'll cut right to the case. I have a JPanel and i call setLayout(null) on it. Simply because I would like to position everything myself and haven't seen a handy manager yet. Now i need to add this panel to a JScrollPane and this is where all the trouble starts. The JScrollPane simply doesn't like the absence of a LayoutManager.
I have been trying to puzzle through this for hours now and could use some help.... -
It seems i already found the answer, for people who are searching for the same answer here is the solution:
Code://Before this was Slot* instead of Slot**, meaning that i was conferting it. Slot** ForgeScreen::getSlots(){ return slots; }...Code://Before this was Slot* instead of Slot**, this has to change because the return value of the get method has changed and we dont want to make
Leave a comment:
-
Problems with arrays and pointers
Hi,
This is some code in the first class:
Slot is another class i defined of which i want 2 objects.Code://the array of pointers Slot *slots[2]; //the get method for the previous array //The first error occurs here: error C2440: 'return' : cannot convert from 'Slot *[2]' to 'Slot *' Slot* ForgeScreen::getSlots(){ return slots; }
... -
Thanks for the article. I wanted it to be easy to read for Humans.
~BSCode266Leave a comment:
-
XML serialization
Hey,
Right now i am using serialization to xml and i looked around a bit but couldnt find the solution so i thought i'd ask here. My "problem" is that the xml i serialize doesn't look as it should but appears all in one big line. I have been trying to find out how to tell the serializer to do this correctly but couldn't find it.
Does anyone know how to do this?
Thanks in advance,
... -
I think this should work.Code:String s; if(s != null){ here you go; }
BSCode266Leave a comment:
-
Ah okey, thank you once again Jos. I just wanted to know what i was doing was acceptable. :D
BSCode266Leave a comment:
-
I am glad that you worked it out all by yourself. And sorry if i just looked like a smart-@ss. I truly wanted to help you out, just couldnt find the thread.
BSCode266.Leave a comment:
-
Would it be smart to use a txt as some sort of database.
Hey everyone,
Right now i am making a program for children which are physically challenged. The purpose of this program is to have children express feelings by playing. So in this game i will need alot of objects out of the real life but also fictional ones. About 100 objects for now. I have made up a menu-structure so that this can be fully operated with just 2 buttons. Because of this i had to group objects together in categories.... -
The way i have used it before isnt probably the best way but it works. You can add the textarea to the scrollbar. And then the scrollbar to the panel.
i think its just one of the scrollbar.add() method.
BSCode266Leave a comment:
No activity results to display
Show More
Leave a comment: