Sam Kaydee

Greenhorn
+ Follow
since Mar 16, 2014
Sam likes ...
Android Chrome Java
Merit badge: grant badges
For More
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 Sam Kaydee

Hello Everyone,

I couldn't find the right forum so I am posting this in the " Java in General " forum.

I am developing a audio/video chat application and tried using JMF but there is significant delay ~1-2 seconds even when both the PCs are in the same LAN. I have heard of FMJ but haven't used it yet. Can you please suggest any other alternatives to JMF ?

I have also used the webcam-capture API. It can successfully capture the video from default webcam and display it but does not have any options for transmitting it to another user.

Thanks in advance.
8 years ago

I don't understand what you mean by that. An applet IS a class. Look at the beginning of your code -- doesn't it say "public class Something" there? As for the manifest, you don't need a Main-Class line entry for applets.



I am sorry that was a typo,what I meant was that an applet does not have a main method.The export options of eclipse requires me to specify a main class. However in a java applet there is no main class!

Is there a particular reason you're writing an applet?



Actually it was a Swing based application and everything was fine with but I had to convert it to an Applet for a friend and problems came pouring in

The applet runs perfectly in the appletviewer provided by JDK. So,basically I should have a HTTP server running to test if my applet isn't having any problem in the browser.is that right?

And is there any way that I can allow File System Access to the applet?( like Signing it?)
9 years ago
Hi,

I am quite new to developing Applets in java. I recently made an applet that will play a particular sound whenever a button is pressed. The sound files are placed in the same directory as the applet class file and i access them by using .

The Applet runs fine in the appletviewer but whenever I try to open it using any browser like Chrome,IE,Firefox the applet loads but sound isn't played. I checked the java console and it showed "java.security.AccessControlException: access denied ".
My questions are:
1. How do I allow the applet to get access to those files?
2. When the Applet is running from the local file system why CAN NOT I access those resources via getCodeBase() ???
3. I googled and found that I can sign a JAR and that can have full access to the computer. But how do I create a JAR from an applet (which has no Main method) while it asks me to point to the main class in the manifest?

Thanks in advance.

P.S: I also found this Oracles's Java Security
9 years ago
In Binary Search, you have a sorted list.{suppose Ascending order}
1.Check the middle element and compare with your value.
2. If your value==mid then it is found.
3. If your value > middle element, you have to search the upper part of the list i.e now your lower bound will be mid and the upper bound will be array size.
4. Else your value is in the lower part of the list i.e your upper bound will change to mid.
5. Continue this until the element is found.


Now implement this in your case and you are done!!
10 years ago
Please look into your binary search algorithm. What you have written now is


Now this will be AN INFINITE LOOP. You have asked the while loop to run if low<=high whereas you haven't modified any of their values inside the loop.So the condition will always remain true and the loop will keep on running.
10 years ago
What would be a good and simple algorithm to find the shortest route between two points in a 2D array[grid] ? There can be certain obstacles in the grid i.e. some of the cells may be inaccessible. I tried googling for it and found that A* is the best for this but I am just a beginner and would like to start with something much simpler.

Thanks in advance for your tips and suggestions.
10 years ago

Joanne Neal wrote:
Without seeing the moveTop method, there's not much more help you can be given.



Here is the moveTop() method:
10 years ago

Joanne Neal wrote:

brandon mac wrote:Joanne,
At the moment, you enter the while loop when the salary is between 0 and 250000. You actually want to enter it when the salary is outside that range.
Try




Did you try this??
10 years ago

Joanne Neal wrote:So what do the results show ? Is it actually returning from the moveTop method ?
Your program is obviously stuck somewhere - either in the moveTop method or possibly in the moveBottom method but before any output has been generated.



The method moveTop() moves an animated piece one block forward in the applet window and i don't think that it it stuck in the methods because this is not specific to the moveTop() or moveBottom() method. It is executing only the first command of the else block (line 11) whatever i use there is executed.
And about the methods we dont have access to those,we can use them but cannot modify anything in them.

P.S: Only one action can be taken in a turn so when (turn!=0) it goes into the else part and executes the first line.. is it like that?? if yes how can i get past it.
10 years ago
We have been given a simulator to check our code..it's basically a java applet. I just have to run the applet to see the results.
A demo code is also given which will control the opponent.
10 years ago

brandon mac wrote:Joanne,
I tried to use the && instead of the || and that didn't fix it either.



You want to have a salary value between 0 and 250000.right?
but in the condition of the while loop you are checking (salary >= 0 && salary <=250000) which will loop for every value in the range. So,suppose your input in 5000, now that should be a valid input (isn't it??) but in your current logic it will still go into the loop and rerun the code.
So what you want is to check the conditions of your loop i.e you want a positive number for salary but also the value should not exceed 250000.
10 years ago
Hi everyone! This is my first post so do correct me if i do something wrong..

Okay so we were told to design a basic AI for a turn based game much similar to Archimede's Chess. There is a 8X8 board and each side has 6 pieces numbered from 1-6. One of them is the King and the rest are pawns.
King can move 1block either vertically or horizontally and have power =2.
Pawns can move 1block in any direction and have power =1. Further there are 4 blockers placed randomly to block certain blocks.
At the 0th turn the King has to be appointed [mandatory] and no other action can be taken.

Killing Rules:
1.A piece will only be taken if it is surrounded by more enemies than friends i.e the summation of power of enemy is greater than summation of power of friends. [here surrounded means the immediate neighboring blocks]
2. At a time only one piece can be killed.
3. Game ends if the King is defeated or after 25 turns.

What I have done:
My logic is simple.
Check the neighboring cells, if ally present then move forward else move towards direction of ally.

This way my pieces will stay in cluster so they wont be taken easily and in case a opponent comes within range it will be killed because my piece will most likely be surrounded by more allies. (This does not have a very high probability of success,but this is what I came up with...suggestions are verry welcome!!]
This is the method which runs the pieces:


This method checks for neighbours:


P.S: All the movement are already defined as moveTop(),moveBottom(),moveTopLeft() etc
VarGame.w.setKing(piece number) sets the king.
VarGame.w.getTurnNo() gives the currnt turn.
VarGame.w.warriorLocations returns a 6X4 matrix with col1= piece number,col2=row address,col3=column address,col4=power
Problem:
Now I'm having problem at keeping track of the turns.The code runs till appointing the king and the next command but does not move further .
Also it would be nice if you have some suggestions as i'm new to this and your experience will be very valuable!!.
10 years ago