generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Can I ask help for java?

Previous Thread :: Next Thread 
brad9873 is not online. brad9873
Joined: 26 Jul 2009
Total Posts: 3208
08 May 2012 08:48 PM
I know this place is for Roblox scripters, but I have a problem with some java code and decide I could possibly ask you guys if you know any java?
Report Abuse
Wowgnomes is not online. Wowgnomes
Joined: 27 Sep 2009
Total Posts: 26255
08 May 2012 08:48 PM
[ Content Deleted ]
Report Abuse
crazyman32 is not online. crazyman32
Joined: 13 Apr 2008
Total Posts: 18027
08 May 2012 08:51 PM
I'm still learning it, but know a decent amount
Report Abuse
brad9873 is not online. brad9873
Joined: 26 Jul 2009
Total Posts: 3208
08 May 2012 08:53 PM
Well I was creating an object for an enemy when I encountered a problem.
I will give you the object I created but not the main class unless you need it. I just made the objects first and I haven't messed with the actual methods and the main method.
Here is the zombie object:

class Zombie {
enemy zombie = new enemy();
health = 10;
String name = "Zombie";
chance = (Math.random() * 10);
void fight(){

}
}

I was trying to force the math.random into an int. I haven't started the fight method yet. The problem is that on the "enemy zombie = new enemy();" it says I need a , instead of ;. Also on the chance it says I need an extra ) to complete the block.

Note;
I am using eclipse to help me.
I have not really worked on the rest of the code.
The enemy is the main class.
Very basic I know.
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
08 May 2012 09:18 PM
I need ALL classes you're using in order to fix it.
Report Abuse
SDuke524 is not online. SDuke524
Joined: 29 Jul 2008
Total Posts: 6267
08 May 2012 09:19 PM
Can you give us the EXACT output please?
Report Abuse
brad9873 is not online. brad9873
Joined: 26 Jul 2009
Total Posts: 3208
08 May 2012 09:25 PM
All the classes(2, Just started the script. Very basic.)
Enemy Class:


class enemy {
int health;
String name;
int chance;
void fight(){
}
}


Zombie Class:


class Zombie {
enemy zombie = new enemy();
health = 10;
String name = "Zombie";
chance = (Math.random() * 10);
void fight(){

}
}
Report Abuse
crazyman32 is not online. crazyman32
Joined: 13 Apr 2008
Total Posts: 18027
08 May 2012 09:26 PM
Just extend enemy instead perhaps?
Report Abuse
brad9873 is not online. brad9873
Joined: 26 Jul 2009
Total Posts: 3208
08 May 2012 09:27 PM
@Crazy
I could do that but I have been practicing with objects lately and I decided this would be a nice way to. I wanted to try it out and this is the problem I encountered.
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
08 May 2012 09:32 PM
Yes, do what CM says.



class enemy {
    int health;
    String name;
    int chance;

    void fight(){
        // no modifiers? i suggest just making it public
    }

    public enemy(int health, String name, int chance) {
        this.health = health;
        this.name = name;
        this.chance = chance;
    }
}



class Zombie extends enemy {

    void fight(){
        // again i suggest the use of public here
    }

    public Zombie() {
        super(10, "Zombie", (int)(Math.random()*10));
    }
}


class Test {
    public static void main(String[] args) {
        Zombie monst = new Zombie();
    }
}
Report Abuse
crazyman32 is not online. crazyman32
Joined: 13 Apr 2008
Total Posts: 18027
08 May 2012 09:34 PM
Wewt I actually knew something about Java for once! I'm learning ;')
Report Abuse
brad9873 is not online. brad9873
Joined: 26 Jul 2009
Total Posts: 3208
08 May 2012 09:34 PM
I was going to fill in the methods after this. I plan to have multiple objects so that is why I was wondering why this wouldn't work.
Report Abuse
xFortunato is not online. xFortunato
Joined: 25 Nov 2010
Total Posts: 865
08 May 2012 09:34 PM
Is it possible to use Java with Roblox or is this just some playing around with a zombie class in Java?
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
08 May 2012 09:36 PM
Roblox does not use Java.


What do you mean by "using objects" ??
When you "extend" an object (known as inheritance), you're creating an object anyway.
Heck, everything in Java is an object. Even those darned error messages.
Report Abuse
SDuke524 is not online. SDuke524
Joined: 29 Jul 2008
Total Posts: 6267
08 May 2012 11:27 PM
My OOP stuff on roblox has extends in it if you need to take a look fortunato. Also you would only be able to use java on roblox if you made your own custom compiler, which would be a pain and if you were to do something like that on roblox you should really make it your own custom markup or scripting language so that it has more functionality here.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image