~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I do have one thing to ask though just for clarification on point 4. I think I understand but you mean that I should lean more towards using the constructor than using the mutator methods?

Yes. So instead of:

Person p = new Person();
p.setName("sos");
p.setAge(666);

prefer

Person p = new Person("sos", 666);

To add to this, if you don't plan on changing the fields after the object is created, you can also mark them as final and be rest assured that there won't be any accidental assignment or mutation to these fields. It doesn't make a lot of difference in a single threaded program but become really important when you start using threads. Shared mutable state (i.e. sharing a Person object between two threads wherein the fields are mutate/can be set) can lead to headaches as the system grows in size. So for e.g. if you are asked to add a new song to the playlist and remove an existing one, instead of "mutating" or modifying the object you plan on removing, it's better to actually remove a given song object and add a new one. In short, stay away from unnecessary mutation! If you want to know more or need a detailed snippet to showcase the problem, just let me know and I'll write it out for you.

Does that come with the netbeans installation or is it a plugin that I can install seperately?

Some IDE's like Eclipse come …

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

A few more if you are game:

  • Use camel casing when naming methods/classes/variables etc. as opposed to snake case (e.g. MP3Player as opposed to MP3_Player)
  • Don't blindly provide getters and setters for every field in your class. For e.g. you already have addSong and removeSong methods in your code; why provide a getter for songList. This is made worse by the fact that since songList is mutable, I can add/remove songs without triggering your checks which is not a good thing. If you still have to provide a list of all the songs, wrap up your list in an immutable wrapper which the user can iterate but not mutate.
  • Think twice before adding methods; for e.g. why do you need a default constructor for MP3_Player?
  • Favor constructor initialization over setters
  • Be extra careful when validating user input. Currently you check for blank titles i.e. "". What happens if I pass in " "? Is that a valid title? If not, does your code catch that?
  • Try out testing frameworks like JUnit for testing/validating your code.
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I would add KurageHime to that gender-bender list; I have seen the anime adaptation and it's good IMO.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Also what I heard. Hopefully it will finish things off nicely :)

Assuming they will stay true to the LN's, this series won't end anything since there seems to be a follow up novel.

Yahari Ore no Seishun Love Come wa Machigatteiru

For some reason I have mixed thoughts on this one. The genres for this anime are something which I do watch but the endless chatter somehow turns me off. I'll give this a shot.

Hataraku Maou-sama

This is one of the main highlights of this season which holds exceptional promise. Romance - check, comedy - check and fantasy - check. This is something which slipped my attention when writing the first post so I've added it now.

Photo Kano

Pretty much a fan-service series which almost non-existent story. I don't have high hopes for this one.

Suisei no Gargantia

First episode has got me and I believe a lot of folks hooked. If they can carry this through, this series will surely have an avg rating of around 8.

Yuyushiki
Aiura

Meh. ;)

Hentai Ouji to Warawanai Neko

For some reason, the MC of this anime reminds me of the MC of DxD. This series has the right amount of comedy, seriousness and fan-service. Another "holds good promise" series I would say.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Waiting for the java version of the API...When can i expect a java version?

Daniweb API is web based (or more technically a RESTful) API and as such doesn't require a language specific version of it. It's HTTP all the way. All you need to use the API in Java is a HTTP client library (like Apache HTTP Client), a JSON library like Jackson and you should be good to go. If you are still unclear about the concepts, search around for "java rest client" or something along those lines.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Finally getting the second season of Railgun. I felt that the second season of Index did nothing but set up Railgun to take over as the main show and I was a bit disappointed as Index had a lot of potential.

I think there is enough material in the ToAru LN to justify a third (or maybe even a fourth) season. I believe it will happen eventually, though if you ask when, your guess is as good as mine.

Just started watching Mirai Nikki (NSFW)

Mirai Nikki rightfully falls in the "psychological" category of anime along with others like "School Days", "Now and Then, Here and There", "Berserk" etc. I normally try to stay away from these shows as they make me a bit uncomfortable but in the end I can't resist the temptation and end up watching them anyway. ;)

There is rumour of a third seasons of Bakemonogatari. Know anything about it?

Monogatari - The series is slated to air in July as is a sequel to the Nisemonogatari series.

Back on track, I'm cautiously optimistic about Shingeki no Kyojin. Hope it doesn't turn out to be another Naruto/Bleach/Fairy Tail.

Given the current anime scene in general and more specifically the "action" ones, I really won't mind another Fairy Tail, Bleach etc. More DBZ power-ups FTW!

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

A bit late to the party but...

so i thought id ask if there are other people who love cartoons/anime too?

Yup, I'm an avid anime viewer with around 150 days of anime viewing time, which IMO is quite a significant number (maybe pales in comparison to deceptikun's?). If you ever feel like tracking your anime viewing history and at the same time chat a bit with like-minded folks, give MyAnimeList a try.

in dragon ball z , what happens at my place ( country rather ) they get to a really interesting point in the show , like where majinboo hatches and then poof... back around 100 episodes... and the loop continues 3 or 4 times! it killed my interest in the show...

I have pretty much given up on Animax. If you really are interested in watching or picking up a series, just search around for online anime viewing sites; there are lots of them. These sites provide you the flexibility of viewing anime at your own pace. After all, there isn't a lot you can do if you want to watch anime and live in a country like India with practically zero anime market.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Howdy folks,

Apologies for posting this a bit late than usual; normally I post this thread a few days before a new season starts so this technically isn't a preview, but oh well. Anyways, the chart showing the different anime which airs this season can be found at Neregate.

Unfortunately, this season looks a bit meh (but still better when compared to the upcoming Summer, but I digress). I have seen the first episode of pretty much all of them and the ones to look out for specifically IMO are:

Are you specifically looking out of any of these or would you rather wait for the 2nd season of "Katekyo Hitman Reborn" to start airing. ;)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Does it still fail; it shouldn't fail. What does your new XML look like?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I don't know how to do this but I can help you out with the where to look question. You need to look into the concept of CID's also known as content ids. Basically, you create a multipart message and assign a content ID to the image attachment/data which will be used as the src for the image.

http://stackoverflow.com/questions/4312687/how-to-embed-images-in-email
http://stackoverflow.com/questions/5260654/embedding-images-into-html-email-with-java-mail
http://stackoverflow.com/questions/2996514/inline-images-in-email-using-javamail

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You need to think why a code is written before adding in code. When you write: hello helloworld = (hello) context.getBean("helloworld");, what are you expecting it to return back? How do you think Spring will get back the hello object for you?

Take a few minutes and read the error message carefully. The error basically means "the context XML file which you have loaded doesn't have a bean called 'helloworld'" which is correct. Now the question is how can we fix this error? You already have defined a bean in the XML file but it isn't named "helloworld". How do you think can we do away with this error? Can you think of a way of replacing or modifying the code such that your class Main works?

On a related note, always put your class in package and follow Java coding conventions. hello is not a good name for a class. Also put this and the Main class in some sort of a package like test.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I no longer program in Spring but IIRC, id names in Spring follow the Java variable naming conventions and hence ids can't be just numbers (which is what the exception message is trying to convey here). Change id="1" to id="one" and see how it goes.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The next step should be checking if the libs exist or not. Try out the suggestion in the following thread (i.e. creating a symlink for the missing directory assuming you have the libswt files). If it still doesn't work, clean remove Eclipse using your package manager and try the installation again.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

logfile url is wrong

There is nothing wrong with the URL.

I've just tried to install eclipse on my linux laptop. I have oracle java 7 installed, but I am getting an error (see below). Can anyone point me in the right direction to get Eclipse installed? I don't know what to do next.

Need more details; can you post the URL where you downloaded Eclipse from? A few things you can check for:

  • Check whether you have a 32 or 64 bit OS
  • Ensure that the correct version of Java is installed
  • Ensure that you are downloading the correct version of Eclipse (x86 vs x86-64)
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You need to be either a sponsor, team colleague or part of the Daniweb team to be able to set custom titles.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

StoreReporter.class.getResourceAsStream doesn't do what you expect it to do. It tries to load a resource and return the corresponding stream relative to the class. Replace it with a new File(yourpath) and let us know how it goes.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Which IDE are you using for development? Use a debugger a check why that line has a null root. The assignment on line 56 seems to be causing the problem because you don't do a null check on the root before using it on line 49.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The specification explicitly talks about little endian data and NUL (\0) terminated strings (like C programming language). You are better off using FileInputStream which reads raw bytes and handle them explicitly in your application. Java uses big endian so default method calls (readInt etc.) won't get you anywhere.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Trace your algorithm on a piece of paper before making changes. The code right now directly returns the left subtree node if the left sub-tree is non-null, something which is not desirable. Your top two conditions (the first two if's in the search function) are correct. The third if..else needs to be replaced by two if's. Something like:

  • If left sub-tree is not null, search left sub-tree (you had this correct in the previous attempt)
  • If right sub-tree is not null, search right sub-tree
  • Return null if all else fails
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Looks good though there is a small issue. Normally the factory method/classes used for the flyweight pattern have the same signature as the constructor of the object which you want to cache. Your solution looks more like a static cache since there is no capability of creating new chemicals on the fly if they don't exist.

The client code should ideally use the factory as follows Chemical c = ChemicalFactory.getChemical("Sulfer", "S", 32.0);.

On a related note, if you already know the number of items you can have in all, prefer using an Enum with an helper class, which offers a bit more type safety.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

That's a good question!

JUnit and Servlets (basically your web apps) are frameworks. What a framework does is it runs the code you write which adheres to some common guidelines (e.g. in the case of a JUnit test, you either extend the class with some JUnit class or decorate the methods with the @Test annotation).

As to how it happens, its done entirely via reflection in both the cases. JUnit has the concept of "runners" or basically classes which run the test code. When you right click on the file and say run as JUnit test case, the Eclipse JUnit plugin calls one of the runner classes (in case of Eclipse BlockJUnit4ClassRunner) with the fully qualified name of your class to be tested. After that, it's all reflection magic by creating an instance of your test class, grabbing the special JUnit methods and executing them in some sort of wrapper/controlled environment.

In case of web apps, you specify the servlet fully qualified name of the servlet class in the web.xml file. The servlet container takes this name, tries to load and instantiate the class dynamically and if it succeeds, casts the object an appropriate servlet type (e.g. HttpServlet). I know this is all hand-waving and the details might deviate but the general idea remains the same. The web container/servlet container is very much aware of all the applications you have deployed, the URL's it is supposed to handle, the mapping between a given URL and a servlet etc. Thus, when …

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Replace the else in the search method with another if statement which checks if the right sub-tree is not null and checks it.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Now I have a problem with finding values on the right subtree.
I have added some code, that will search for a letter that was entered by the user, if it is found it will increase the frequency of the letter.

It will output for the root, and the left subtree, but does not return anything for the right subtree.

This is because you never search the right sub-tree if the value isn't found on the left sub-tree. You need to change your condition so that both left and right sub-trees are searched in your search method of the Tree class. Also, I hope you are aware that you lose the "find node in logarithmic time" feature offered by the search trees if you don't create your tree based on value but the number of nodes it has.

Another question.... Am I supposed to compare string values for the input for a balanced binary tree?

I'm not sure I understand this question: you are already searching for the nodes based on their string values?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

It's OK as long as you are consistent within a given code base though generally not recommended if it is meant to be consumed (used and read) by a wider audience (i.e. other Java developers). Also, in your case, you are better off with naming the variable as dead and the getter/accessor method named as isDead (if you have an accessor method that is).

IMO, just stick to the official Java coding convention and it should work out fine.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

That's a pretty strange binary tree. Normally, insertion criteria is based on the "value" attribute of each node which helps you determine where to insert a node into a tree and at the same time, how to "search" for a node inside the given tree. With the number of nodes used as an insertion criteria, how do you plan on finding a given node in the tree?

Anyways back to the question; with the current code, the output of A B D F C E is expected. Trace the tree on a piece of paper for the input you suggested. What kind of tree do you get? Any reason why you think A B D E C F should be the output?

EDIT: Gah, replying to a stale thread...

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

It isn't really that complicated IMO; just use jLine; it works out of the box on Windows (and I believe *nix too)

Try out this simple snippet after adding the JAR to classpath:

public class Test {

    public static void main(final String[] args) throws Exception {
        ConsoleReader reader = new ConsoleReader();
        Character mask = '*';
        String line = null;
        do {
            line = reader.readLine("Enter Password(blank pwd to exit)> ", mask);
            System.out.println("Got password: " + line);
        } while (line != null && line.length() > 0);
    }

}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Harinath, though I can see that your intention was to "lighten" up the Java forum with your humour, this really isn't the best place for it; next time for programming related humour try the Geek's Lounge.

Also, let's refrain from personal attacks here. I'm closing this thread now.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Please provide me the solutions to bundle jre inside jar and how to run a jar?

Without unpacking the zip file and setting the appropriate paths? I doubt.

There is a free tool called launch4j which supports creation of launchers for JAR files and embedding a JRE (as mentioned on the home page) but you might have to do a bit of reading to get it to work (it requires you to create a XML file for its configuration). You might get some leads in this thread.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I was faced with a similar situation in the past and decided to adopt a completely different approach. Since you really don't care about the key, I'm assuming this is some sort of a default case and no custom mapping has been added. In that case, something like this worked better for me:

// map => LinkedHashMap to maintain the ordering
if (map.isEmpty()) { // no custom mapping
   return config.getDefaultMyClassInstance();
} else {
   return map.get(yourKey);
}

Of course, might not fit your use case here; just throwing out some random food for thought.

EDIT: If using something like Python, the solution can boil down to a single line:

val = mapping.get( your_key, default_object )
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

, the other is a scripting language, which can only run front-end in a webbrowser.

This isn't true; look at Node.js. It provides all the API calls required to do I/O (network connections, read/write files etc.), integrate with other C/C++ API's out there (by writing node.js libraries which wrap them) etc. In short, a stand-alone Javascript implementation. Of course, it isn't the first; there are others like Rhino, an implementation of Javascript in Java.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I think you can get the best of your endorsement system by looking at the endorsements of those who you think are trustworthy/endorseworthy since there is a high chance they will endorse folks with some merit. But I agree, it's more of a personalized benchmark; you might disagree with what I agree with.

tux4life commented: I agree. +0
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Folks, let's not turn this thread into a warzone. I'll close the thread by saying this:

IMO no one in this thread is copying other solutions or posting ready-to-use entire solutions; neither James nor IIM. I can't control personal opinions (manifested via means of up/down-votes) but let's just admit that all of us, at some point in time have either posted short one-line answers or full code snippets to help out the OP. Let's not forget the real reason of why we actually spend our free time on this forum; to help out people without causing problems for others. I don't think anyone in this thread is guilty of anything. To offset random downvoting, I have upvoted the posts accordingly.

If someone wants to take this further, I would be more than happy to discuss things via PM.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The documentation told me that base 10 was assumed if you didn't pass in the second argument!!

Oh noes, there is no such thing specified in the specification. The MDN goes to great lengths to even mention this:

An integer that represents the radix of the above mentioned string. Always specify this parameter to eliminate reader confusion and to guarantee predictable behavior. Different implementations produce different results when a radix is not specified.

:)

EDIT: If you plan on always dealing with base 10 numbers, using the Number constructor is a safer option.

tux4life commented: :) +0
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Moral of the story: Don't trust parseInt() to work the same in Firefox as it does in Chrome.

I'm really interested now, details please. And while we are at it, were you passing in the second argument to parseInt? If not, bad Dani. :)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

This normally happens when the download is incomplete. Can you check the size of the file on your HDD and compare it with the expected size? Also, try using a download manager like Flashget if the browser download manager isn't working out for you.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

if one of the attributes of my class is a String, would that be an object inside my class???? Teacher says it's simply a variable...

There is no String inside your object. Keeping aside primitives for the time being, if a class is composed of multiple fields having different reference types (anything which derives from an Object), those names are nothing but references or pointers. There is no actual data being stored in your object. This distinction is important because you have the same object referred from multiple objects. If you think that a field is inside some other object, you might mistakenly think that each object has a copy of the field data which isn't true.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Consider using enums for Suit and Rank instead of raw strings, much safer and saner approach IMO.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

what are some basic things or steps you can advice..thanks

Start small and start quick with a rough design sketch in your head/paper. Don't be bogged down by the big picture. Always try to divide stuff into small bits and pieces. The first and foremost focus should be to get it working. How it is done depends a lot on your way of thinking: some start by identifying the primitive parts of the application and writing it piece by piece. You can have your own preference.

As your system evolves, be prepared to throw away your code if need be. The day you replace a 100 line code with a 20 line one (of course same functionality and more elegant) should be a good day for you. :)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

My mind automatically translates that to "you are too stupid to understand this so let's just say it's magic"

For me it's more like "you really shouldn't care about this so let's make a joke out of it and call it magic". Of course, YMMV.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

It's not a typo, it's a slang term.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Creating new sub-forums is pretty much out of question these days since the focus/shift for the new Daniweb is more towards tagging stuff rather than creating new categories for things.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I was wondering if a microcontroller or arduino section could have a home here. Or would that be best classified under "Software Development\C", or other various languages that can be used for more than 1 type of hardware?
Or Raspberry Pi, would that be a "Linux and Unix" thing, or something else?

There are multiple options. If you are writing it in C, posting it in the C section and adding a relevant "tag" should be good enough. Similarly with Python and other langauges; depends on the language your code snippet is in. Or, if your code is in a language which is not natively supported by this forum or it contains a dash of multiple languages, you can post it in the top level Software Development category and tag it accordingly.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

but lack of multiple inheritence is troublesome

Lack of multiple inheritance is a problem if you don't have traits (Scala) or mixins (Ruby). If Nimrod has any of those, it should be fine IMO.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I agree with AD here. Plus, since Markdown (the markup format used by this site) doesn't support any of this natively, we'll have to hack up the Markdown specification to our custom needs. Doable, but not really favored since the target audience percentage is very small plus it requires maintaining a Daniweb flavored Markdown format. A custom markdown format isn't bad per se (SO and Github use it); it's just that a lot of thinking has to go in to adopt something like that for Daniweb.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

After Bill Gates wedding night, his wife finally knew why he called his company Microsoft.

Making fun on others using a suggestive mature theme; not a good joke Michael...

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Dani, maybe you should add the API announcement/link to API in your sig because it seems that the link posted on the very first page is broken?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The problem is with closing parentheses. Just escape the closing parentheses by leading it with backslash character and it should work out fine. For e.g.

http://docs.oracle.com/javase/6/docs/api/java/util/Arrays.html#asList(T...) [without backslash]

v/s

http://docs.oracle.com/javase/6/docs/api/java/util/Arrays.html#asList(T...) [with backslash before the )]

EDIT: It seems like there is a bug in the MD renderer. The preview shows the complete URLfied URL for the second case but after a submit it disappears.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

application/x-www-form-urlencoded (the content type when you do form submissions in browser) should also work out fine I think; the API is basically expecting POST data.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

This news is a great step ahead I think. I'll take a look at this API when I reach home. In the meantime:

Not right now. (Gosh, should I say that in public?)

You can implement a rate-limiting feature similar to something used by Github I think. Each user (or some user group) can implement X API calls per day / per hour etc. Once that limit is reached, all further API calls return a denied HTTP status.

EDIT: Also, this opens up a distinct possiblity of a clean slate implementation of a true mobile compatible Daniweb.

tux4life commented: Good suggestion :) +0
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I have mixed emotions about it. What if I don't want the same avatar on all web sites that I visit?

Then maybe provide an option to override the gravatar image? But IMO this seems too much effort for something not too significant, especially when there are more important things to be tackled (chat, spell checker etc.). :)