Pawno into Java - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: Other (
https://sampforum.blast.hk/forumdisplay.php?fid=7)
+--- Forum: Everything and Nothing (
https://sampforum.blast.hk/forumdisplay.php?fid=23)
+--- Thread: Pawno into Java (
/showthread.php?tid=637941)
Pawn into Java -
MattTucker - 24.07.2017
I've been watching tutorials, reading books, reading java documentation to get to know it better before I start out my college, so I can get that background info/knowledge.
But I've been wondering, if maybe I am to create a game
basically on pawno we do stuff like
Код:
enum pinfo
{ pPass, pScore, p... };
To acccess player attributes/variables in an easier way
So I was wondering, how can I do such thing in java?
EDITED: Pawno to pawn - pisses a lot off
Re: Pawno into Java -
AndreiWow - 24.07.2017
https://docs.oracle.com/javase/tutor...vaOO/enum.html ?
Re: Pawno into Java -
Mauzen - 24.07.2017
Java is object-oriented. You would basically create a class that contains all attributes and work with objects of that class.
Код:
public class Player {
private String pass;
private int points;
// ...
public Player(String pass, int points, ...) {
this.pass = pass;
this.points = points;
// ...
}
}
Player p = new Player(...);
Take a look at the java plugin for samp, it got some example code that might give you a better idea.
Re: Pawno into Java -
Vince - 24.07.2017
I don't know where you live but most colleges start from absolute zero regarding things like this. In Java (or any other OO language for that matter) you would create a class for this with getters and setters. In the actual main code you instantiate a new object of that class whenever you need it.
Re: Pawno into Java -
MattTucker - 24.07.2017
Thanks for the informative replies.
I've had the main idea as creating a class with setters and getters but I wanted to do the pawn-way of the enum thing as I won't be needing to create too many functions but I guess no way around it.
Quote:
Originally Posted by Vince
I don't know where you live but most colleges start from absolute zero regarding things like this. In Java (or any other OO language for that matter) you would create a class for this with getters and setters. In the actual main code you instantiate a new object of that class whenever you need it.
|
They do start from the absolute zero over here as well, I just wanted to be better prepared.