Joson Mathew

Greenhorn
+ Follow
since Aug 05, 2014
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
19
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Joson Mathew

Jeanne Boyarsky wrote:Joson,
It's still a good book and all the examples will work with Java 8 SE.

After you finish the book, you'll want to read an upgraded book on the Java 7/8 features.



Thanks for the quick, clear reply.
6 years ago
I am somewhat familiar with the basics of Java, like OOP concepts and loops, stuff like that, but I have practised entirely on BlueJ.

I wanted to get used to text editor-command prompt barebones Java (without an IDE) so I downloaded Java SDK 8. I was planning to use
Thinking In Java to help further and strengthen my Java knowledge, but the book says SE5/6.

Does this make a whole lot of difference? Should I go ahead with this book anyway? Is there any other book you recommend?
6 years ago
Brilliant! I have got a good understanding of how it is done now. So to change the number of seconds, I just change 3000L to 10000L right (3s to 10s)?

I had to make a change to the program though, I just erased the whatever there was in the bracket in the main method as I didn't know what to enter there. What String am I supposed to enter there and what for?
For some reason I had to wait for a long time for the terminal window to appear. Was that on a timer too lol?

Still haven't understood what the parameters for c.roll object mean, or why we are importing so many packages for a timer. Could you tell me what each package is for?

How I can keep two timers, that reset after different time periods but start at the same instant? All this has to be done in a method in a particular class.

Say, I am using class Xyz in which there is a method sword().


9 years ago
I want to import java.util.Timer into my text game where I have a balance-based combat system in which the opponent attacks every 10 seconds and the player regains his balance after 5 seconds after every attack. So it goes on in a loop until someone's hit count reaaches a particular number, depending on the opponents health.

Unfortunately I have no idea how to do this and am very bad at creating objects and other stuff.

Would be nice if someone would give me a detailed explanation. Please tell me if this thread should be in the beginner forum instead.

Thanks in advance!
9 years ago
True. But say if I only want to upload a class to one of these forums on the Ranch, I can just upload the class file and it will work right?
9 years ago

Tim Cooke wrote:Is it just one class file? If so why not just copy it in the same way you would any other file?

If it's for a school class then I'm sure your teacher is going to want to see the source code too, which is the .java file.


Didn't see your comment there. Thanks for the help and the quick reply. You're right, I guess my brain went dead or something.
9 years ago
Got it. Just the transfer the project folder from My Documents. It was so obvious, why am I so dumb? :/
9 years ago
I have made a program on BlueJ but need to transfer the class to a pen drive so that I can take it to school and show it to my teacher. How is this done?

Please reply ASAP, must reach school in less than an hour and a half.
9 years ago
Thanks all, got some reading to do now. This thread may be closed, ADMIN.
9 years ago
I've got a good idea now. Could you give me a link to a simply-written article where one could read in depth about this particular topic? The Google results are quite overwhelming...
9 years ago
The only thing I have done relating to objects is creating constructors, but everything so far has been within one class. I have imported packages like io, but never linked two classes together. There's a reason I posted this in "Beginning Java" you know. Will Google for stuff.
9 years ago
I am creating a VERY basic game but the combat part gets pretty complex so I want to do that part in a different class.

I understand this is a basic concept but I can't find the corresponding link in the Ranch, would be nice if someone sent mt the link to that or to some other site that explains it well.
I want to be able to import (or whatever else the correct term is) methods of that class into the main class, to make things less complicated. Plus, it's compulsory for my project.

Thanks in advance!
9 years ago
All right, I'll make the switch from function to method as soon as I'm done with school. Don't want to mess up my board paper. Thanks everyone. Any ADMINs around, feel free to close this thread.
9 years ago

Paweł Baczyński wrote:

Joson Mathew wrote:However, I need my 'method' to remain void as I need to use System.out.println inside the method, although that is not shown in the program here. I can't use that in your method can I? What are my options?


Have you tried calling System.out.println from a method that returns int? What happened?



Often the best way to find out if you can or can't do something is to try it.

Further, if you are going to make such bold statement, you might want to provide some supporting evidence - i.e. "My textbook says..." or "According to the Java Language Specification..."

When you do try it, and "it doesn't work", post your code showing what you tried, and tell us exactly what happened.



I feel like a fool. Thank you all for your help. My problem is solved. I don't where I got this notion from and why it was so firmly fixed in my brain.
9 years ago

Jesper de Jong wrote:Welcome to the Ranch.

Arguments to methods are passed by value in Java. That means that if you call a method, for example doSomething(n); in line 5 of your second code snippet, then only the value of the variable 'n' is passed to the method 'doSomething' - not the variable 'n' itself. Inside the 'doSomething' method, the value is assigned to a new variable (called 'i' in your code). If you change the value of the variable 'i', then the value of 'n' in the main method is not affected, because 'n' and 'i' are different variables.

You can't directly do what you want to do in Java. Instead of trying to modify the value of a variable that you pass in to the method, make the method return the desired value, and assign it in the 'main' method.



You sir, are an epic genius. However, I need my 'method' to remain void as I need to use System.out.println inside the method, although that is not shown in the program here. I can't use that in your method can I? What are my options?
9 years ago