Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 are there procedures like turning?
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
magicman




PostPosted: 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
Sponsor
sponsor
[Gandalf]




PostPosted: 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




PostPosted: 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




PostPosted: 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. Smile

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


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




PostPosted: 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




PostPosted: 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




PostPosted: Tue Sep 06, 2005 5:24 pm   Post subject: (No subject)

And there are far worse annoyances awaiting you. Wink
Aziz




PostPosted: Tue Sep 06, 2005 9:18 pm   Post subject: (No 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
Sponsor
Sponsor
Sponsor
sponsor
[Gandalf]




PostPosted: Tue Sep 06, 2005 9:24 pm   Post subject: (No 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'.
wtd




PostPosted: 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 Smile


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




PostPosted: 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! Exclamation
wtd




PostPosted: Fri Sep 09, 2005 11:46 am   Post subject: (No subject)

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

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




PostPosted: Fri Sep 09, 2005 2:42 pm   Post subject: (No subject)

Thanx for the help man.
magicman




PostPosted: 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
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 14 Posts ]
Jump to:   


Style:  
Search: