Troncoso
VIP Member
Teach me your ways.
Which ways are that?
Teach me your ways.
Which ways are that?
Math.random() is actually creating an instance of the random class, it's just short cutting it and allows you to call nextInt, nextByte, nextXXXX...Ah, well, I never use the Math class for random, there is actually a Random class you could use.
I don't know how well you know your way around Bluj, but it has a pretty extensive debugging mode. You need to find a set of data that gives you an infinite loop and hard code those numbers into your program. After that, you can set a break point at your while loop and keep stepping through it to see why it's not exiting the loop.
BlueJ is an option for a debugger, if you are using Eclipse as an IDE, it has a built in debugger you can use.I meant teach me how to set up BlueJ so I can figure out why it's looping.
Math.random() is actually creating an instance of the random class, it's just short cutting it and allows you to call nextInt, nextByte, nextXXXX...
BlueJ is an option for a debugger, if you are using Eclipse as an IDE, it has a built in debugger you can use.
Think of using notepad and command line to build your program or Visual Studio (an IDE). Sure you can use notepad and enter commands into a prompt window, but having an IDE is easier and faster. They do other things as well, such as code completion (i.e. type ahead), syntax highlighing. And they typically have a built in debugger so you can step through your code and watch what it's doing
Oh, so Eclipse, BlueJ, Notepad and more are different IDEs... got it!
The only thing I'd say about BlueJ is it's intended for use as a learning tool for object oriented programming in java to beginners. There's nothing wrong with it but you won't see it used outside of the education system.
public void addGame(Game game, String typeGame){
if (typeGame.equals("sugGame")){
if (game instanceof SuggestionGame)
SuggestionGame gameToAdd = (SuggestionGame) game;
public void method() {
Test test = sample.getSomething();
Not the exact way you're thinking, no. What exactly are you trying to achieve? There's probably a better way to do whatever you're trying to do.When this happens I would like the test object to execute a method. Can I do that?
Not the exact way you're thinking, no. What exactly are you trying to achieve? There's probably a better way to do whatever you're trying to do.
Well you could just call the methods in the code where you're returning the object. I don' know how exactly you've set up your code (if you could post some, that would be helpful) but you could have something likeWhat's going on, is, the user picks from a list of options, when they enter their choice, the object that is specified by that choice is returned, and printed on the screen via the toString() method.
Well, not only do I want that option to print it's toString method, but I also want to call another method. The object is created before hand, so putting it in the constructor wouldn't help.
Object methodThatReturnsObject() {
Object object = theOneObjectYouWant;
System.out.println(object);
object.someOtheMethodYouWantToCall();
return object;
}