Author |
Message |
magicman
|
Posted: Sun Aug 14, 2005 2:35 pm Post subject: are there procedures like turning? |
|
|
Im making a game in turing and im using procs in the program and im goin to transfer the program into java, is ther procedures in java? i know that they will be another name. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
[Gandalf]
|
Posted: Sun Aug 14, 2005 6:09 pm Post subject: (No subject) |
|
|
A procedure is just a function that doesn't return any value, so why not do that in Java? A function in Java is a method btw. |
|
|
|
|
|
MysticVegeta
|
Posted: Tue Sep 06, 2005 1:39 pm Post subject: (No subject) |
|
|
I am new to java so this might be a little bad code but feel free to correct me
code: | //A procedure that outputs something.
public static void myProc {
System.out.println("Something");
}
|
Now...
code: | //A function that returns an "int" product of 2 ints.
public static int Multiply (int a, int b) {
return a * b;
}
|
|
|
|
|
|
|
wtd
|
Posted: Tue Sep 06, 2005 2:14 pm Post subject: (No subject) |
|
|
MysticVegeta wrote: I am new to java so this might be a little bad code but feel free to correct me
code: | //A procedure that outputs something.
public static void myProc {
System.out.println("Something");
}
|
Now...
code: | //A function that returns an "int" product of 2 ints.
public static int Multiply (int a, int b) {
return a * b;
}
|
You've got the basics. However, all method names should begin with a lower-case letter.
Also, use the Java syntax highlighting.
code: | [syntax="java"][/syntax] |
Oh, and please indent, and don't leave spaces between the parameter list and the method name. |
|
|
|
|
|
[Gandalf]
|
Posted: Tue Sep 06, 2005 3:01 pm Post subject: (No subject) |
|
|
Quote: and don't leave spaces between the parameter list and the method name.
I'm not liking these Java conventions... |
|
|
|
|
|
rizzix
|
Posted: Tue Sep 06, 2005 3:47 pm Post subject: (No subject) |
|
|
that's not just a java convention.. it's a C/C++/Perl/and quite a few other langs that support a C-like syntax.. convention... get used to it.. it's the way the world works.. |
|
|
|
|
|
wtd
|
Posted: Tue Sep 06, 2005 5:24 pm Post subject: (No subject) |
|
|
And there are far worse annoyances awaiting you. |
|
|
|
|
|
Aziz
|
Posted: Tue Sep 06, 2005 9:18 pm Post subject: (No subject) |
|
|
wtd wrote: And there are far worse annoyances awaiting you.
Amen to that.
And yes, there are procedures in java, like turing, but the Java program is strictly Object-Orientated. EVERYTHING is an object. Turing is a procedural language . . . things are done in procedures. So your program is an "object" and the object has methods (procedures/functions), and fields (variables). The methods belong to the object. The object can use the methods, or if the methods are public other objects can either create an instance (like taking a blueprint and making something new) and use it's function (if it's non-static) or it can call on the object's method through referencing through the object, like this: MyObject.myMethod(); These methods are "static" methods, meaning they're attached to their class. I hope I'm right. rizzix/wtd, Please correct |
|
|
|
|
|
Sponsor Sponsor
|
|
|
[Gandalf]
|
Posted: Tue Sep 06, 2005 9:24 pm Post subject: (No subject) |
|
|
Hmm... Maybe I could just ignore it altogether?
I just don't understand it. Having spacing between the brackets, spacing after the method name, and a whole bunch of other stuff makes the code so much more readable. We need more whitespace!
Ah, it doesn't matter either way. If it's so important I will learn it some time, right now I am mostly programming 'for fun'. |
|
|
|
|
|
wtd
|
Posted: Tue Sep 06, 2005 9:26 pm Post subject: (No subject) |
|
|
Aziz wrote: These methods are "static" methods, meaning they're attached to their class. I hope I'm right. rizzix/wtd, Please correct
More or less right, though as I specify in the Introduction to Java thread in Java Tutorials, perhaps a better term is "context". |
|
|
|
|
|
magicman
|
Posted: Fri Sep 09, 2005 11:11 am Post subject: (No subject) |
|
|
alright, all of that talk just confused me a whole lot more!!!! can any one tell me what they were saying in basic retard terms. Is there something easyer that what the people were posting??? HELP! |
|
|
|
|
|
wtd
|
|
|
|
|
magicman
|
Posted: Fri Sep 09, 2005 2:42 pm Post subject: (No subject) |
|
|
Thanx for the help man. |
|
|
|
|
|
magicman
|
Posted: Wed Oct 05, 2005 11:28 am Post subject: (No subject) |
|
|
alright. I think i got it. so i use..
code: |
//A procedure that outputs something.
public static void myProc {
System.out.println("Something");
}
|
to make the procedure. but how do you play or run the procedure?
and yes i can't spell and yes i am lazy |
|
|
|
|
|
|