Win a copy of Programming with Types this week in the Angular and TypeScript forum
or The Design of Web APIs in the Web Services forum!

Gopi Balaji

Ranch Hand
+ Follow
since Jan 23, 2003
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
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Gopi Balaji

Jim,

Thank you for your response. I got a notification of your reply to this topic at my new email address. So, I think it has taken effect.

I have subscribed to the Journal/Newsletter and the Tuesday(?) emails about Book Promotions. I do not get any other emails from the 'Ranch.


Thanks,
-GB.
15 years ago
Site Managers,

I changed the email address in my profile a while back. But, I still get JavaRanch email (about the Book Promos and the Journal/Newsletter) at my old email address.

How long will it take for the email change in the profile to take effect?

Thanks,
-GB.
15 years ago
Thanks Nagaraju..
I do not have access to the Admin console, and will look up more on this.
-GB.
15 years ago
Hello folks,
Can a standalone WAR be installed in WAS 5.0?
The WAR is not part of any EAR. Is it possible to install it? Should an EAR be installed for a WAR to be installed successfully.
I appreciate all inputs.
-GB.
15 years ago
1. The command line tools "get" and "pcli" should be in the PATH environmental variable.
2. Use the optional ANT task pvcs as described in ANT's documentation
-GB.
15 years ago
I suspect that the version string is not valid. Can you check what error messages are logged to the console?
-GB.
16 years ago
A possible explanation :
Does the attribute "version" of "j2se" element have a restricting version specified?
Say, if the client has JRE 1.2 and JRE 1.4.2 installed, and the version attribute's value is "1.2", the 1.2's rt.jar is used, instead of 1.4.2's.
-GB.
16 years ago
I think it is an excellent situation wherein the adoption of a rule engine would do good. Check out a Javaranch's bartender's book - Jess In Action.
If you think a rule engine is too general, and are adventerous, you could come up with your own expression/rule language tailored for your domain.
-GB.

Originally posted by Jim Yingst:
[damian]: I know that I could access the path as well as the filename of the class I choose from the FileChoser. I could then find the package name from the path if I knew the start of the package.
It may be awkward, but this sounds like your best bet. Let's say the complete path is
/foo/bar/baz/a/b/c/MyClass.class
I'd try these in succession:
Class.forName("MyClass")
Class.forName("c.MyClass")
Class.forName("b.c.MyClass")
Class.forName("a.b.c.MyClass")
Class.forName("baz.a.b.c.MyClass")
Class.forName("bar.baz.a.b.c.MyClass")
Class.forName("foo.bar.baz.a.b.c.MyClass")
The first one of these that returns != null, that's your class.


Or... you can write your own class loader (or use URLClassLoader), and load the class file selected by the user. Once this is loaded, you can use reflection to find the package the class is in, or do whatever else you'd want to do with it.
-GB.
16 years ago
A possibility -
If server2 supports the telnet protocol, open a telnet session from servlet1 in server1 (or a helper class thereof) and execute the process in server2.

-GB.
16 years ago

Originally posted by Joel McNary:

<snipped />
Gopi, I'm not sure what you did wrong, but We get different results for a 6-card deck with a cut of 3:
<snipped />
Your top and bottom cards never change; you are dropping the bottom card from the bottom stack first (as opposed to the bottom card from the top stack)


Ahh.. I see. This is something that should be pretty easy to change in the code.. Perhaps, after the change, you can use this code to confirm the working of your solution.
The approach of your solution is noble. I have read your explanation.. yet to read the code.
-GB.
16 years ago
Did not find time to confirm the validity of the results.. but, anyway, here is my code.
Card.java

CardFacory.java

CardStack.java

Dealer.java

PerfectCut.java

Please comment.
-GB.
16 years ago

Originally posted by RArun Kumar:
What is the result for shuffles(1002,101).I am unable to find the result for shuffles(1002, 101). It runs for hours. Can anyone tell the algorithm to solve this problem. Any help is appreciated.
Thanks,
Arun


I wrote a small set of classes.. and got the answer as 66.
I got the answer within ~10 seconds..
Can anybody confirm the correctness of this answer? I will post the code after I find time to confirm it myself. (I tried a few other combinations.. 66 is the max answer I get..)
P.S. : I did not use any fancy algorithm - just brute force.
-GB.
[ June 19, 2003: Message edited by: Gopi Balaji ]
16 years ago
'int's and 'double's are not objects, and it is difficult/convoluted to apply Object-Oriented design patterns here. If you use their object wrappers (Integer, Double) instead, this is an excellent candidate for Strategy.
You can even have ComplexFloat, ComplexShort if has any meaning.
The Visitor pattern has too many disadvantages to be used casually.
-GB.

Originally posted by Ilja Preuss:

That link doesn't seem to work
And I don't understand why you'd need Singleton here - it seems to me as if AbstractFactory would totally suffice (and be more flexible).


Its strange.. the link as quoted in your post works, but not in my original..
Well, in the instance quoted here, it is an AbstractFactory. The Singleton pattern is superimposed on it, to ensure that there exists one and only one instance of the AbstractFactory, or any one of its children.
If the AbstractFactory, and its mutliple ConcreteFactory classes were not Singletons, then they could be instantiated at will. You would not want this, if you want the user to use only a specific and particular child of the AbstractFactory.
On the other hand, if you force all your programmers to instantiate only a particular child (say either declaratively like use.factory.implemntation=USAVehicleFactory, using a properties file, or hard-coding it like USAVehicleFactory.getInstance()), then you would tightly couple (degrees vary on method chosen) your code to that particular implementation of the factory.
The clients of the AbstractFactory interface are aware only of that class. They have no compile time dependency on the children of AbstractFactory. As described in that example, the source for the child of AbstractFactory class did not even exist when the client was coded and even shipped.
Using the AbstractFactory pattern here allows you to switch the factory implementation to create different products. Using the Singleton pattern here allows you to remove the client's compile time dependency on the implementation.
-GB.