Pokemon Server Archive

PvP Server => Plugins => Topic started by: 1cec0ld on May 23, 2012, 03:29:02 am

Title: What I've done
Post by: 1cec0ld on May 23, 2012, 03:29:02 am
My level 5 Charmander:

Code: [Select]
package me.yourname.HelloWorld;


public class HelloWorld  {
public static void main(String[] args){

System.out.println("hi");

}
}

I leveled up!

Code: [Select]
package me.yourname.HelloWorld;


public class HelloWorld  {
public static void main(String[] args){


int number = 4;
if( number < 10 ){
System.out.println("hi");

number++;
}

}
}

Code: [Select]
package me.yourname.HelloWorld;


public class HelloWorld  {
public static void main(String[] args){


int number = 4;
if( number > 10 ){
System.out.println("hi");

number++;
}
else{
System.out.println("hello");
}

}
}

Code: [Select]
package me.yourname.HelloWorld;


public class HelloWorld  {
public static void main(String[] args){


int number = 4;
while( number < 10 ){
System.out.println("hi");

number++;
}

}
}

Idk if I'm evolved or not. Probably level 12 or something.
Title: Re: What I've done
Post by: ArchieSalt on May 23, 2012, 03:52:47 am
What da fuq is this?
Title: Re: What I've done
Post by: liquidfired on May 23, 2012, 04:22:17 am
epic java work. Keep going, I right now am learning more of Cinemas 4D at the moment. Maybe I could make a Pokemon Server Animation :P
Title: Re: What I've done
Post by: ~Ali~ on May 23, 2012, 04:23:49 am
Not bad at all. I could give you some tips, if you'd like.

I'm now working on the Unreal Engine, making a game on the iOS.
Title: Re: What I've done
Post by: Paradox on May 23, 2012, 05:05:43 pm
Conditionals and while loops!?!! THIS IS MADNESS!


Also, your second and third snippits of code won't work as I think you would want. I'm a summing your increment the number so it'll actually increment next time, but it won't. You initialize the integer inside the method bodies, so once the method ends and you call it again, number will be 4 again, not 5.
Title: Re: What I've done
Post by: 1cec0ld on May 23, 2012, 05:53:44 pm
I ran the code and it printed hi 6 times as I expected? It assumed 6 endLines which surprised me, but I'm not complaining.
Title: Re: What I've done
Post by: Paradox on May 23, 2012, 07:27:25 pm
I ran the code as well and it printed it hi way more than 6 times, which is what I expected. How are you running your code exactly...?
Title: Re: What I've done
Post by: 1cec0ld on May 23, 2012, 08:22:21 pm
(https://www.pokemonserver.net/forum/proxy.php?request=http%3A%2F%2Fi259.photobucket.com%2Falbums%2Fhh305%2Fjeretry%2Fasdf.jpg&hash=b217439f7c1a5c7cfec39c356638da99)
Title: Re: What I've done
Post by: Paradox on May 23, 2012, 08:26:55 pm
Yeah, that's the while loop one. I said the second and third one. Those didn't work, your while loop looks fine.
Title: Re: What I've done
Post by: Anonymouslyanon on May 23, 2012, 08:38:49 pm
Wait, what is all of this stuff?
Title: Re: What I've done
Post by: Paradox on May 23, 2012, 09:42:22 pm
Those are basic Java programs implementing difference concepts. Mainly conditionals and loops.
Title: Re: What I've done
Post by: 1cec0ld on May 23, 2012, 09:57:53 pm
OHHHH I'm a derp.
Yeah that last increment in the if() statement is just me working backwards, I'd already done the while() loop and wanted to show more basic stuff, so i started deleting and then writing the if() stuff. I just forgot to remove the increment line, it literally has no purpose in those sections.

Any ideas on what I should do/practice next? I don't know what I need to learn/brush up on without a direction that leads me to plugin development in the long run.
Title: Re: What I've done
Post by: Paradox on May 23, 2012, 10:37:38 pm
What objects are and how to use them. That's literally it. Once you understand that you can start to develop, most of the methods are already written for us because of the bukkit API. IF you understand objects, we can start to work together and you'll learn mostly from there.


http://docs.oracle.com/javase/tutorial/java/concepts/ (http://docs.oracle.com/javase/tutorial/java/concepts/)
Title: Re: What I've done
Post by: 1cec0ld on May 24, 2012, 12:35:42 am
This was fun  :haha:

Code: [Select]
package me.yourname.HelloWorld;

//main puts things together into something
public class Assemble  {
public static void main(String[] args){


//2 versions of the thingy
thingy thing1 = new thingy();
thingy thing2 = new thingy();

thing1.printOut();    //instance 1 as default
System.out.println(); //newline

thing1.changeSecondChar( 'w' );
thing1.changeThirdInt( 1 );
thing1.changeFifthInt( 5 );
thing1.changeSixthChar('n');


thing2.printOut();     //instance 2 unchanged
thing1.printAfter();   //instance 1 changed


}
}


class thingy{

int third = 3;
int start = 1;
    char second = 'c';
char sixth = 'l';
int fifth = 0;
char seventh = 'd';

void printOut() {
System.out.print( " " + start + second + third + second + fifth + sixth + seventh );
}
    void printAfter(){
    System.out.print( " " + second + third + sixth + fifth );
   
//This is ticking me off. I have to add the ( " " + blah ) or else
//it defaults to print( int i ); instead of print( string s );
//like a retard, and adds the ascii values up and prints a number.
//Totally stuck here.
   
   
    }


void changeSeventhChar( char newLetter ){

seventh = newLetter;
}
void changeSixthChar( char newLetter ){

sixth = newLetter;
}
void changeSecondChar( char newLetter ){

second = newLetter;
}
void changeStartInt( int newInt ){

start = newInt;
}
void changeThirdInt( int newInt ){

third = newInt;
}
void changeFifthInt( int newInt ){

fifth = newInt;
}
}


However, 2 questions.
1. How do I fix my print( string s ) problem? Each int/char is supposed to append onto the string, but, it defaults to print( int i ) unless i add that space in quotes to the beginning. (Adding it to the end didn't help)

2. Can I optimize my changeDataThing( newData newThing ) methods? Instead of writing a separate method for every single field I declared, can I somehow pass them to a single method for that data type?
Title: Re: What I've done
Post by: 1cec0ld on May 24, 2012, 12:45:19 am
whoa freaky stuff if i initialize:

Code: [Select]
thingy thing1 = new thingy();
thingy thing2 = thing1

 :O_o:

I thought it would copy the fields and methods and be separate after that line...
Title: Re: What I've done
Post by: Tenebrae on May 24, 2012, 07:18:03 am
This was fun  :haha:


Seems like your enjoying it :P
Title: Re: What I've done
Post by: Paradox on May 24, 2012, 04:43:05 pm
whoa freaky stuff if i initialize:

Code: [Select]
thingy thing1 = new thingy();
thingy thing2 = thing1

 :O_o:

I thought it would copy the fields and methods and be separate after that line...


Not freaky, it's called pointers. When you use non-objects for initializing, like
int i=5;
int j=i;


They're different but just have the same value. But with objects, you point to the same reference. You need to make them initialize different or else they point to the same piece of memory, i.e if you change anything in thing1 it'll change what's in thing2.
Title: Re: What I've done
Post by: CalDaBeast on June 28, 2012, 09:29:21 pm
Isn't java FUN!??

Just to show-up 1ce, a snippit of code from one of my plugins...
Which one will I choose?
olyForge! https://github.com/CalDaBeast/olyForge/blob/master/src/com/olympuspvp/caldabeast/olyForge.java
Don't you just love Java?