Xer0botXer0

Members
  • Content count

    8
  • Joined

  • Last visited

Community Reputation

120 Neutral

About Xer0botXer0

  • Rank
    Newbie

Recent Profile Visitors

302 profile views
  1. Do I need to use "throws xException" in a method name, because I don't always see it used even though a try catch is used in the method ?
  2. I'm thinking about keeping a collection of code that's relevant to each other in some documentation, I'm going to look at evernote it looks promising!
  3. Are you one of the people who learnt this from personal experience or did you listen to the suggestions of others ? I'll be one of the people who learn this from personal experience. Yes it may take me 20/30 years, that's 20/30 years of experience in mmos instead of 20/30 years of experience in small projects that mean nothing to me. For clarity, I am not making an mmo in Java. I am making a server in Java. It's not as difficult as you present it to be, it's an exciting road ahead.
  4. Hi guys, So something I'd find useful is having like a reference book/cook book for the languages I'm learning. For example I'm currently busy with a tutorial that's talking about client/server networking in java, so far I've written the code and made a bit of sense on what's going on, how ever I want to break things down by line, like how you'd go to oracle to see what the documentations say about the difference libraries, their methods, exception types and all that. I'd like my own version that only has what I've already learnt or what I'm currently learning/what's relevant. I'm looking for a way to create documents and then organize them so they're easily accessible and navigable , I'm sure if I were a better programmer I would make something like that but I'm more a game dev, so what do you use(if any) to do this sort of thing ? do you know of any software like that ? I'm finding crap on google and thought well other developers may use something of the sort. I used to use a book and write down what I've learnt into sections so I could look back for quick reference. But I'm not a fan of my handwriting and I type much faster.
  5. Thank you, This is kind of a dilemma, how would I keep my program from not closing on its own ? It doesn't make sense that a program should ever close on its own and only when specified by a close button or such. I'm trying to create a server, so what if I do something like.. public class main{ boolean awake = true; while (awake) {//run all the code} } Would this work ? In this server example I dont see anything like this. So I'm not sure how it's staying alive.
  6. Hi guys, Can I see Javas Main class as a main loop in which everything inside will be run continuously ? This is confusing because at the start of the main class in my code sample two class objects are created and one array object. I'm not sure about the process. In GML there's a section where code is only run once, and then there are sections where scripts are continuously run. And of course if I only want code thats in the section which runs continuously to only run once I'd use a boolean.
  7. I'd have to disagree with going with what you know works, rather than seeing if what you want can work. I'd receive a lot of discouragement over making an open world mmo rpg, How ever I've been working on it for some time and I go with what will work for me, as an example.. I use GMS for my game project which requires a server and a client, after reading up I learnt that a GML server will not be able to support the amount of players and amount of activity my game will require.. so their suggestion ? make a four player coop game, or something like that. My answer ? I considered it, I won't be doing that, what could work ? So here I am learning Java, because a Java server for my GML client will work and satisfy my needs.
  8. Hi guys, So I'm looking at another developers project for learning purposes and I'm just moving through the code so I can get an understanding of what's happening and how to write my own version of it. And the first thing I'm looking at is the 'try ..catch' statement. From what I can tell the purpose of try catch is to try a block of code and if an exception occurs then catch it, In this example I'm not sure how catching is actually working. try { Thread.sleep(1); } catch (InterruptedException e) { } I've also seen some basic examples where 0 is divided by a value and it's suppose to throw an Exception, the person then draws a line to say hey you can't divide like that. But in this case what will happen ? I think more importantly, if an error occurs, does the program crash, and whether or not it crashes will I see a message in Eclipse console telling me what caused the error ? And then, from what I've read some peoples approach is to determine what exceptions/errors may occur and then change their code to prevent that from happening. These questions will help me understand whether or not I can take the following approach, code, run the program, attempt all possible interactions, when an error occurs see what it says in the console or rather see what interaction I did that caused it then modify the code to prevent that from happening, instead of catching exceptions. Update: I looked up exceptions a bit, I see that InterruptedException is a specific exception that throws when a sleeping thread is interrupted using the interrupt(); method. And that I don't see interrupt being used in the project then the exception is actually not required.
  9. Hi guys, So I feel like I've learnt a bit, not much! but I'm getting somewhere. So I'd like to create a road map to work towards, my reason for learning java is to create a java based game server that uses SQL for data storage.  So this question is directed to people that - if you think about creating a game server then a few ideas come up about how you'll go about it, I'm looking for that sort of information. More along the lines of the things that come up while thinking about the process. Also a bit of specifics will help.  Thank you!   
  10. Isn't that the same as this .. public class House { public String address; // a constructor with a parameter public House() { // the constructor's job is to do setup on a per-object basis } public static void main(String[] args) { House Toms_House = new House(); Toms_House.address = "21 Java Street"; System.out.println(Toms_House.address); // prints: 21 Java Street } }
  11. I'm trying to reference objects, so far I have this, I have moved onto lists.   package myPackage; import java.util.*; public class Server { public static void main(String[] args)  { List list_Players_DB = new ArrayList(); Players_DB Player = new Players_DB(); list_Players_DB.add(Player); Players_DB Player1 = new Players_DB(); list_Players_DB.add(Player); list_Players_DB.add("hmm"); for (int i=0; i < list_Players_DB.size();i ++) { System.out.println("Players_DB Object REF:" + list_Players_DB.get(i)); } } } I'm getting this result:   Players_DB Object REF: myPackage.Players_DB@7852e922 Players_DB Object REF: myPackage.Players_DB@7852e922 Players_DB Object REF: hmm   I was expecting that it prints unique values for each of the two objects.   I've changed it to this, just to see what's going on, I'm now adding object variables to the list or rather their values and printing that.   package myPackage; import java.util.*; public class Server { public static void main(String[] args)  { List list_Players_DB = new ArrayList(); Players_DB Player = new Players_DB(); Player.player_id = 0; list_Players_DB.add(Player.player_id); Players_DB Player1 = new Players_DB(); Player1.player_id = 1; list_Players_DB.add(Player1.player_id); list_Players_DB.add("hmm"); for (int i=0; i < list_Players_DB.size();i ++) { System.out.println("Players_DB Object REF: " + list_Players_DB.get(i)); } } } And get this output:   Players_DB Object REF: 0 Players_DB Object REF: 1 Players_DB Object REF: hmm     The whole idea is that I want to reference the objects themselves.. say an object has an ID. And I was using my first code block, I'd expect an output like   Players_DB Object REF: 0x0301 Players_DB Object REF: 0x0302 Players_DB Object REF: hmm   Right, from there When I want to retrieve one of the variables within these objects i'd do something like   for (int i=0; i < list_Players_DB.size();i ++) { String obj_ref = list_Players_DB.get(i); System.out.println(obj_ref.player_id); } which should still print out this  Players_DB Object REF: 0  or what ever the value of that referenced objects variable is. :/ That's what I'm aiming for.    Okay! So I tried out your method, this is giving me the results I want YES! XD package myPackage; import java.util.*; public class Server { public static void main(String[] args)  { //attempt 1 List list_Players_DB = new ArrayList(); System.out.println("Attempt 1:"); Players_DB Player = new Players_DB(); Player.player_id = 0; list_Players_DB.add(Player.player_id); Players_DB Player1 = new Players_DB(); Player1.player_id = 1; list_Players_DB.add(Player1.player_id); list_Players_DB.add("hmm"); for (int i=0; i < list_Players_DB.size();i ++) { System.out.println("Players_DB Object REF: " + list_Players_DB.get(i)); } ///Attempt 2 List<Players_DB> players = new ArrayList<Players_DB>(); players.add( new Players_DB()); players.add( new Players_DB()); Players_DB what = players.get(0); Players_DB what1 = players.get(1); System.out.println(""); System.out.println(""); System.out.println("Attempt 2:"); System.out.println(what); System.out.println(what1); } } Here's the results:   Attempt 1: Players_DB Object REF: 0 Players_DB Object REF: 1 Players_DB Object REF: hmm     Attempt 2: myPackage.Players_DB@7852e922 myPackage.Players_DB@4e25154f   As you can see I'm getting two different IDs now!  I noticed that I didn't put the correct variables in at the first attempt which is why I got the same ID twice, I changed that and also get two IDs there. I'm not sure which of the two approaches to take..   your method: List<Players_DB> players = new ArrayList<Players_DB>(); players.add( new Players_DB());   mine: List list_Players_DB = new ArrayList(); Players_DB Player = new Players_DB(); list_Players_DB.add(Player);   Hmm, I'm just happy with the results.  Thanks dmatter
  12. Thanks for clearing this up, so with what I've gathered here I'll write an example, from there I've got a question regarding constructor parameters but let me write it first. package Sims; public class House {    public House() //House class Constructor (no parameters)    {    }         public static void main(String[] args)     {           House Toms_House = new House();     } } If my above code is correct, I've got one class "House", with a constructor for the class "House" without parameters, I then have a line of code in the main class which creates a new object of the class House where the object name is "Toms_House". Also, this new object of House will have no variables, but if I add variables to class House and assign values to those variables, they will be copied over to the new object of House called "Toms_House" ?   The reason I'm asking if the new keyword makes an exact copy of the 'schematic' class House, is because I don't understand what the parameters are for within the constructor. I think I need to start off with understanding what parameters are used for, before asking why they are used in the constructor. Some potatoes are complaining about me creating multiple posts even though they are different, so I'll rather ask here for now. I'm going to read up a bit about parameters/arguments, then I'll update this post. 
  13. Yes the problem is that I don't understand the syntax for the 'new' keyword which is what I'm currently looking up. What is happening in the code you've provided ? Is it allocating 5(6) slots within the Arr_Players_DB[] Array, creating a new Players_DB object then adding it to the array ?  I see you're not initializing the array size before hand. There are two ways to approach learning, There is the learn everything about something and then there's learning only what is relevant to the applications it's needed for. The one makes you more capable with a larger area of understanding, while takes longer and you may learn things that you'll never use, how ever may learn things that you may use, it's a gamble. The other is setting a goal, and over coming barriers on the way to that goal.  The way I would suggest my approach to someone over their approach is by establishing pros and cons with both manners, the reason I say suggest is because it's not always the case that you understand the other persons method. I'm going to stick with learning what is relevant, yes I am all over the place at the moment, but eventually the gap will be closed the more sense I can make of these relevant points.  Thank you for the information so far, there's something new at every avenue, right now I'm stumped with how I want to reference objects in an array, in your code it looks like you're creating the objects at the same time as assigning them to an array. which looks like the way I want to go about it. 
  14. Here's my current code   package myPackage; public class Server { public static void main(String[] args) { int Arr_Players_DB[] = new int [5]; //array object initialization for (int i = 0; i < Arr_Players_DB.length ; i ++) { Arr_Players_DB[i] = -1; //Initialize array } for (int i = 0; i < Arr_Players_DB.length; i ++) // //populate array { Players_DB player = new Players_DB(); if (Arr_Players_DB[i] == -1) { Arr_Players_DB[i] = player; }}}}   Error message is "Type mismatch: cannot convert from Players_DB to int"   Because I want a list, each list ID must be a reference to each object, each object holds variables which will equal to properties that I've assigned for each object. These will be for "Players" in the game in a server side application. So it makes sense that I should try and reference each object in an array.    The reason I've moved from using a 2D array for this is because Multidimensional Arrays in java require that each dimension be the same data type, which is a problem when I want to store "username String" and "password Integer"(for example).   I had a look at Identity and equality, all it's showing me is that objects can be referenced by creating a new object type and storing another object in that. Referencing yes..   So the idea then is when I create a new array int Arr_Players_DB[] = new int [5]; //array object initialization That the data type be that of an object, but that would work would it ?        They're all regarding java, and can be boiled down to reveal many similarities, how ever they are not the same. If you are not going to contribute to the topic then don't post. You are trying to be helpful, how ever let me help you understand that I am browsing the web while creating threads because it's things I've found on the web that don't make sense, specifically mentioned above regarding multidimensional arrays requiring the same data type which is when someone in that thread (not my thread) recommended referencing objects in arrays instead. So I'm not being lazy, or trying to make your day a little more difficult by scrolling by an additional 400 pixels to find a post worthy of your assistance. I'm trying to learn Java. So far this works for me.    An object has a memory start address which is unique for each object. That is being used for identity checking (ie ==). The default implementation of "equals" also uses that (except for some standard objects like integers, reals, and strings, and such). By overriding "equals" you can have your own equality notion between objects. (However, given the kind of questions you ask, this is currently a little too far for now, so something to keep in mind for later.)   Edit: Sorry, I was talking total nonsense about equals: primitive types (int, double/float, and boolean) have no equals, and use == as equals. class-types (ie everything else than primitive types) have both == and equals, which may or may not check the same thing.   This is similar to the link provided by Avalandor, there's an image which shows that each object holds a space within memory. What's new is that you're saying they have unique start addresses, I don't think It's suppose to get that complicated to find these addresses just to make a list of objects that can be referenced. 
  15. Im not doing anything regarding inner classes.  See here if you wish: https://www.gamedev.net/topic/689300-updating-reading-from-an-array/