Community Member
Member Avatar
Topic by sing1006 in Software Development
It can be done, but you have the wrong approach. You must create the Element objects, and then create/set the Text in them. You will need to add the Element objects to the appropriate parent Element objects. And then you will have to serialize (write) the XML as characters to … Reply by JeffGrigg
Member Avatar
JeffGrigg 170 Replied To a Post in How to loop the xml with the first node
Topic by sing1006 in Software Development
Here's one way:
`System.out.println("title = " + movie.getElementsByTagName("title").item(0).getTextContent());` Reply by JeffGrigg
Member Avatar
JeffGrigg 170 Replied To a Post in for-loop iteration cant add
Topic by noobjavacoder in Software Development
You already have most of the right stuff there. You are correct in thinking that you do not need a vector, array or list.

Think of how you would total the values stored in an array. You need to do something similar here. You need to add values to the … Reply by JeffGrigg
Member Avatar
JeffGrigg 170 Replied To a Post in Even numbers
Topic by Rachy3091 in Software Development
Farrukh:
We help people with the programs that they write themselves. Please make an attempt to solve the problem yourself. And if you are still having problems, please post a new question on this site, with the code you have written, and we would be glad to help you. Reply by JeffGrigg
Member Avatar
Topic by larnacode in Software Development
1. I don't see any call to the `move()` method anywhere.
2. You probably want to create the Earth outside the loop. Reply by JeffGrigg
Member Avatar
JeffGrigg 170 Replied To a Post in Webservice
Topic by kanakaraj.karre in Software Development
1. ["difference between soap and restful web service" info](http://lmgtfy.com/?q=difference+between+soap+and+restful+web+service)
2. SOAP contains security standards. Restful web services use HTTP security. They can both be secured. Reply by JeffGrigg
Member Avatar
Topic by silvercats in Software Development
Agreed. Some prefer the first to have more visible lines within a single screen.

Code styles are like religion, they'll trigger holy wars. Reply by pritaeas
Member Avatar
JeffGrigg 170 Gave Reputation to JamesCherrill in Threeloops.java
Topic by school12345 in Software Development
You just copy/pasted your assignment without even a moment taken to explain what help you need. That's highly disrespectful to the many people who give their time to help others here.

There are lots of people here who will freely give their time to help you become the best Java … Reply by JamesCherrill
Member Avatar
JeffGrigg 170 Gave Reputation to Ashley157 -1 in Java snacktime bot
Topic by Benny_1 in Software Development
hey i'm in a similar situation as you where i'm trying to program a snacktime bot and i'm lost as to where I should start, would you mind posting your finished code so I could have something to take guidance from? Reply by Ashley157
Member Avatar
JeffGrigg 170 Gave Reputation to Benny_1 in Java snacktime bot
Topic by Benny_1 in Software Development
The class is now over and our bot turned out awesome! There was a giant snacktime tournament and our bot got to the finals! Sadly, for the finals match our teaher add a dog snack that was -500 points. Darn it, should've added something to avoid negatives! Reply by Benny_1
Member Avatar
JeffGrigg 170 Replied To a Post in Java snacktime bot
Topic by Benny_1 in Software Development
Personally, I would make the bot smarter, rather than adding sound. Reply by JeffGrigg
Member Avatar
JeffGrigg 170 Replied To a Post in Java snacktime bot
Topic by Benny_1 in Software Development
> I plan on adding a soundtrack :D

Waste of time.

But it could be cool to growl like a tiger (or something like this) when going to take food from the opponent. Maybe laughing ("Ha, HA!") when you take food that the opponent was heading towards. >;-> Maybe "packman" … Reply by JeffGrigg
Member Avatar
JeffGrigg 170 Gave Reputation to Benny_1 in Java snacktime bot
Topic by Benny_1 in Software Development
Also, I did realize that this was very similar to robocode, and I used to play that game a lot until my classwork became an overload. When this class is over, I'm gonna go robocode crazy :D. Reply by Benny_1
Member Avatar
JeffGrigg 170 Began Watching Java snacktime bot
I'm new in java, so I'm not very good at it yet and my teacher has stumped me. We are supposed to make a bot for a game called snacktime, which is usually user controlled.

# About Snacktime: #

* There are a maximum of 16 snacks layed out randomly … Topic by Benny_1 in Software Development
Member Avatar
JeffGrigg 170 Replied To a Post in Java snacktime bot
Topic by Benny_1 in Software Development
I would very highly recommend using an iterative approach. (...with automated JUnit tests, if you can manage it. ;-)

Like...

Version 1: Always move to the closest snack.

Version 2: Use a simple formula like "snack value divided by distance" to select the "best" snack to head towards.

Then refine … Reply by JeffGrigg
Member Avatar
JeffGrigg 170 Replied To a Post in Java snacktime bot
Topic by Benny_1 in Software Development
> But I'm stuck on the methods for how far I should move.
> ... I have no idea how to calculate the angle (in radians (I hate radians)).
> I might not even need the calc_angle method. I'm not sure where to start.

I would start by taking a … Reply by JeffGrigg
Member Avatar
Topic by thegreymatter in Software Development
This is my solution:

public static TreeSet<Integer> getPossibleLastValue(final int n, int a, int b) {
final TreeSet<Integer> result = new TreeSet<>();
if (n == 1) {
result.add(0);
} else if (n > 1) {
int value = a * (n - 1);
for (int idx = 0; idx < n; … Reply by JeffGrigg
Member Avatar
Topic by Bradoz in Software Development
Solved most of issues, going to recondense single issues alot easier to rea
d Reply by Bradoz
Member Avatar
Topic by Bradoz in Software Development
Cheers.
I have been working on this since i posted it and yes realise i prob shouldnt have posted the whole massive chunk at once.


problem i have now is that it is only multiplying polynomial 1 by the first term of polynomial 2


so 2x + 2 * 5x … Reply by Bradoz
Member Avatar
Topic by Lee_8 in Software Development
Yes, people here will help - but do read the DaniWeb rules first, especially
"Do provide evidence of having done some work yourself if posting questions from school or work assignments"
http://www.daniweb.com/community/rules Reply by JamesCherrill
Member Avatar
JeffGrigg 170 Began Watching Vending machine trouble
After trying different things for about a week i have come to the conclusion i am lost. Can someone please show me how to do this.

This assignment, based on Vending Machine we did in class, you are to now vend six different snacks. The Vending Machine has a capacity … Topic by jones13 in Software Development
Member Avatar
Hey guys im completely new to programming and im complete stuck and any help to comlete my assingment would be greatly appreciated. heres my assingment.
Your task for this assignment is to define multiple classes via inheritance. Your classes should implement various "snacks" including "M&Ms", "Popcorn", etc.

To begin, create … Topic by astrid.deliz in Software Development
Member Avatar
Hi recently while trying to solve a core Java algorithm question I got trapped into a problem.

Let me explain the puzzle.

> There is a series of numbers. where difference between any consecutive
> numbers is either a or b. The 1st number of the series is 0. Our … Topic by thegreymatter in Software Development
Member Avatar
Topic by thegreymatter in Software Development
I made some GUnit tests for it:

import junit.framework.TestCase;
import java.util.TreeSet;

public class SolutionTest extends TestCase {

public void testN0() {
assertEquals(new TreeSet<Integer>() {}, Solution.getPossibleLastValue(0, 1, 2));
}

public void testN1() {
assertEquals(toSet(new int[] {0}), Solution.getPossibleLastValue(1, 1, 2));
}

public void testN2() {
assertEquals(toSet(new int[] {1, 2}), Solution.getPossibleLastValue(2, 1, 2)); … Reply by JeffGrigg
Member Avatar
Topic by salesforce in Software Development
Start by defining a Student class that has instance variables for name. marks etc.
Input the raw data, create the instances of Student and add them to a List like JeffGrigg said.

Java has methods to sort a List:
http://docs.oracle.com/javase/7/docs/api/java/util/Collections.html#sort%28java.util.List,%20java.util.Comparator%29

you need to create one or more Comparators ( http://docs.oracle.com/javase/7/docs/api/java/util/Comparator.html … Reply by JamesCherrill
Member Avatar
JeffGrigg 170 Gave Reputation to ~s.o.s~ in eclipse vs vim
Topic by pwolf in Software Development
I would personally use something like Eclipse/IntelliJ because it "just works" out of the box and makes it easy to navigate complicated projects. Sure, you can use your Vim'fu to do all the same stuff I'm not a big fan of carefully tweaking each and every aspect of an "editor" … Reply by ~s.o.s~
Member Avatar
Topic by astrid.deliz in Software Development

> This is what i have so far.


Please don't think we are fools. We know where you copied that from, and so will your teacher after 15 seconds with Google.
Copying someone else's answers is likely to get you an automatic fail of your course, and possibly being thrown … Reply by JamesCherrill
Member Avatar
Topic by thegreymatter in Software Development
There is something to be said for stepping back from the code and problem, and giving a really good "think" to the problem and how one could solve it.

I found that I can solve it in order `n` time. Properly simplified, it can be done by hand. (Of course, … Reply by JeffGrigg
Member Avatar
JeffGrigg 170 Gave Reputation to rubberman in How to start
Topic by ife_1 in Software Development
Recursion is when a function/method calls itself. This is common for binary search, fibbonacci routines, etc. It is very basic computer science and has nothing to do with Java per se. Read this: http://en.wikipedia.org/wiki/Recursion Reply by rubberman
Member Avatar
Topic by salesforce in Software Development
So you want to read that data into memory -- into something like a `List` or array. And then you want to sort it -- based on "Marks" and "Percentage" it seems. (Presumably, the input would **not** already be in sorted order.)

Now, depending on how you do the sort, … Reply by JeffGrigg