Computer Science Canada

are there procedures like turning?

Author:  magicman [ 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.

Author:  [Gandalf] [ Sun Aug 14, 2005 6:09 pm ]
Post 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.

Author:  MysticVegeta [ Tue Sep 06, 2005 1:39 pm ]
Post 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;
}

Author:  wtd [ Tue Sep 06, 2005 2:14 pm ]
Post 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. Smile

code:
[syntax="java"][/syntax]


Oh, and please indent, and don't leave spaces between the parameter list and the method name.

Author:  [Gandalf] [ Tue Sep 06, 2005 3:01 pm ]
Post subject: 

Quote:
and don't leave spaces between the parameter list and the method name.

I'm not liking these Java conventions...

Author:  rizzix [ Tue Sep 06, 2005 3:47 pm ]
Post 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..

Author:  wtd [ Tue Sep 06, 2005 5:24 pm ]
Post subject: 

And there are far worse annoyances awaiting you. Wink

Author:  Aziz [ Tue Sep 06, 2005 9:18 pm ]
Post subject: 

wtd wrote:
And there are far worse annoyances awaiting you. Wink


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 Smile

Author:  [Gandalf] [ Tue Sep 06, 2005 9:24 pm ]
Post subject: 

Hmm... Maybe I could just ignore it altogether? Laughing

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! Smile

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'.

Author:  wtd [ Tue Sep 06, 2005 9:26 pm ]
Post subject: 

Aziz wrote:
These methods are "static" methods, meaning they're attached to their class. I hope I'm right. rizzix/wtd, Please correct Smile


More or less right, though as I specify in the Introduction to Java thread in Java Tutorials, perhaps a better term is "context".

Author:  magicman [ Fri Sep 09, 2005 11:11 am ]
Post 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! Exclamation

Author:  wtd [ Fri Sep 09, 2005 11:46 am ]
Post subject: 

http://www.compsci.ca/v2/viewtopic.php?t=9576

See "A bit of theory" and "Creating your own methods".

Author:  magicman [ Fri Sep 09, 2005 2:42 pm ]
Post subject: 

Thanx for the help man.

Author:  magicman [ Wed Oct 05, 2005 11:28 am ]
Post 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


: