Pawno into Java
#1

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
Reply
#2

https://docs.oracle.com/javase/tutor...vaOO/enum.html ?
Reply
#3

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.
Reply
#4

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.
Reply
#5

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


Forum Jump:


Users browsing this thread: 1 Guest(s)