Kevin Hamrick

Ranch Hand
+ Follow
since Aug 30, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
2
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Kevin Hamrick

Stefan,

That makes cents(ha) and you get back to the original question. So my make change class would contain, IDK, a list of...values(?) such as 50, 25, etc that represents the coins the user wants to be considered and then in the loop check if the value in the enum is contained in the possible values before doing your calculations or is there a better way of doing that, something else that I am missing about enum?

could you also go further into detail about greedy algorithm? I didn't catch what you are inferring.
5 years ago
Campbell - I get what you are saying and I thought about that implementation but then I thought "toString would always be the same for each coin" I guess you could argue that the value would be as well. I will wait and see what Junilu has to add before doing anything else. Thanks to everyone.
5 years ago
Thank you. I see better now and I have removed the switch statements but to get a more user friendly name shouldn't I over-write the toString something like this?



Thoughts?
5 years ago
Here is what I did....
simple enum


and a class to use it...



It produces this output which is fine...

2 Half Dollar
0 Quarters
0 Dimes
1 Nickles
0 Pennies

But I wanted a way to exclude a coin, like say Half Dollar. I suspect I would need to do it in the calculateChange method but I am not sure how to implement. Any ideas?
5 years ago
I've been programing for a long time but I had never used enum and so I thought I would teach myself this feature. I wrote a simple enum and a test class. The enum represents us coins and my test class uses the enum to calculate the change with the least number of coins. For example, I pass in 95 cents, I get back 3 quarters, 2 dimes. It all works just fine, easy to implement and I see why I should use an enum. Then I thought, what if the person is out of dimes. How could I tell the enum to skip dimes in it's switch statements? I can't figure this one out, how would I make DIME(10) false? Any ideas?

Thanks
5 years ago
I've included comments in the snippet of code to show you what I am trying to do and what is broken. Basically I create a sortable table via another class. Pop that table onto a JScrollpane in my ViewPage class. I then sort the table and it vanishes. The only solution I can think of is to build a false header of buttons for the table and the I should be able to make it work. That sounds like a bad idea to me but I can't seem to fix this part. If I were to do the false header is there a way to set the real table header to not display?



Thanks as always.
15 years ago
Might be a stupid question but...
I've build a few sortable test table applets for a page that I am programming. The tables are rather long-about 500 lines of code because they are sortable. The tables seem to be doing everything I want. Now I have built the rest of the page and I am thinking that it might be best to tweak the table applets into a class that has a function which will return the sortable tables. The I should only have to instantiate the class and add the tables to the main page. I wanted to do this for readability sake. Is this a good idea?
15 years ago
correction-the "if" is executing twice...I posted some code where I was trying some different things...my mistake. Either way, if I click the selected cell then I get to executions.
15 years ago
So here is the code below. The problem is that each time I select a cell from the table the 'else' is executing twice. I am not sure how to fix it. Still new and still struggling with swing,
Thanks

15 years ago
Found a solution here right after posting

http://www.iam.ubc.ca/guides/javatut99/uiswing/components/table.html#selection.
This is the code

Only problem is, it seems to be executing the else twice for each click. I thought it might be my mouse but I've change the properties and it still calls the else twice. ANy ideas on why?
15 years ago
I am trying to give the user the option of selecting a specific row and having the mouseclick return an int value for the row each time they click. It seems from reading the API and other examples that this is something that should be easy to implement but in all honesty I have not been able to do it. I would post my code but I have tried several different things. If someone has done this could you please show me how?
Thanks
15 years ago
Thanks V,
I took a third option and re-installed. Seemed to have worked but I am guessing deleting that bad file would have been wiser.
I am using eclipse 2.1 with a tomcat plug-in. It was been working fine for a month or more. Now suddenly I am having multiple problems. If I try to use <ctrl>,<shift><O> I get
"The resource is not on the build path of a java project"
When I try to open a jsp by clicking and selecting open I get
"Can not open default editor on <page name.jsp>.
Text editor does not have a document provider"
If I go to <Project><Properties> I get
no property pages for <project name>

I have three projects and all are having the same problem. I was using at least some of these features as late as yesterday. The only thing I have done lately was to bring in a classes12.jar file from one project to another but even after that the <ctrl>,<shift><O> was working. That is not to say that the other features were or were not working. I just discovered things were hosed this morning. Any ideas?

Thanks for the help.
I loop through and make some JButtons but they don't display the correct names. Here is what is showing on each button.
javax.swing.JButton[,0,0,0x0,invalid,layout=javax.swing.OverlayLayout,alignmentX=0.0,alignmentY=0.5,border=javax.swing.plaf.BorderUIResource$CompoundBorderUIResource@109fd93,flags=296,maximumSize=,minimumSize=,preferredSize=,defaultIcon=,disabledIcon=,disabledSelectedIcon=,margin=javax.swing.plaf.InsetsUIResource[top=2,left=14,bottom=2,right=14],paintBorder=true,paintFocus=true,pressedIcon=,rolloverEnabled=false,rolloverIcon=,rolloverSelectedIcon=,selectedIcon=,text=MISSION,defaultCapable=true]
and here is the code

As you can see i've done a lot of debugging and trying different approaches but nothing works. All I want are these buttons in the header of my JTable with the specified labels.
P.S. Swing is new to me, if someone could recommend a good reference that would be great.
15 years ago
Thanks Jeff,
That was exactly what I needed. It worked great.
15 years ago