Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Feb 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Need a little bit of help here.

    I need help adding more classes (maps) to this code.
    I've tried almost anything but i cant seem to add more of them.
    Code:
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    
    package ChannelServer;
    
    /**
     *
     * @author Secured
     */
    public class Sector {
        public int Mapmon;
    
        public int[] getMapMonster(int map)
        {
            switch (map)
            {
                case 0:
                {
                    int[] ret = new int[38];
                    int i = 0;
    
                    ret[0] = 2;
                    ret[1] = 2;
                    ret[2] = 2;
                    ret[3] = 2;
                    ret[4] = 0;
                    ret[5] = 0;
                    ret[6] = 0;
                    ret[7] = 1;
                    ret[8] = 0;
                    ret[9] = 0;
                    ret[10] = 0;
                    ret[11] = 0;
                    ret[12] = 2;
                    ret[13] = 2;
                    ret[14] = 4;
                    ret[15] = 4;
                    ret[16] = 4;
                    ret[17] = 2;
                    ret[18] = 82;
                    ret[19] = 2;
                    ret[20] = 2;
                    ret[21] = 2;
                    ret[22] = 2;
                    ret[23] = 0;
                    ret[24] = 0;
                    ret[25] = 2;
                    ret[26] = 2;
                    ret[27] = 1;
                    ret[28] = 2;
                    ret[29] = 2;
                    ret[30] = 0;
                    ret[31] = 2;
                    ret[32] = 0;
                    ret[33] = 0;
                    ret[34] = 2;
                    ret[35] = 0;
                    ret[36] = 3;
                    ret[37] = 102;
                    this.Mapmon = 38;
                    return ret;
                }
    
            }
            return new int[0];
        }
    }

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    You don't make use of any classes here. All you have is an integer array that's 38 items in size. So I haven't a clue what or where you are planning on adding more classes since there's no use of them in the current form.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #3
    New to the CF scene
    Join Date
    Feb 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Whoops. I meant "cases". Like "case 1;" so u can add more items.

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    You add a break command to the previous case, and you simply add more case x: levels.
    PHP Code:
    switch (toswitch)
    {
        case 
    1:
            break;
        case 
    2:
            break;
        
    //...

    In java, you can switch on numbers, enums and chars, and the primitive wrappers, but not on any other type of object including strings, so keep that in mind if you're familiar with languages that allow switches from strings.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #5
    New to the CF scene
    Join Date
    Feb 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I get this error when i added case 2 :
    Error : aajava.lang.ArrayIndexOutOfBoundsExpection : 24
    This is the code i made from your advise.
    Code:
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    
    package ChannelServer;
    
    /**
     *
     * @author Secured
     */
    public class Sector {
        public int Mapmon;
    
        public int[] getMapMonster(int map)
        {
            switch (map)
            {
                case 0:
                    break;
                {
                    int[] ret = new int[38];
                    int i = 0;
    
                    ret[0] = 2;
                    ret[1] = 2;
                    ret[2] = 2;
                    ret[3] = 2;
                    ret[4] = 0;
                    ret[5] = 0;
                    ret[6] = 0;
                    ret[7] = 1;
                    ret[8] = 0;
                    ret[9] = 0;
                    ret[10] = 0;
                    ret[11] = 0;
                    ret[12] = 2;
                    ret[13] = 2;
                    ret[14] = 4;
                    ret[15] = 4;
                    ret[16] = 4;
                    ret[17] = 2;
                    ret[18] = 82;
                    ret[19] = 2;
                    ret[20] = 2;
                    ret[21] = 2;
                    ret[22] = 2;
                    ret[23] = 0;
                    ret[24] = 0;
                    ret[25] = 2;
                    ret[26] = 2;
                    ret[27] = 1;
                    ret[28] = 2;
                    ret[29] = 2;
                    ret[30] = 0;
                    ret[31] = 2;
                    ret[32] = 0;
                    ret[33] = 0;
                    ret[34] = 2;
                    ret[35] = 0;
                    ret[36] = 3;
                    ret[37] = 102;
                    this.Mapmon = 38;
                    break;
    
                }
    	                case 1:
    			{
    			int[] ret = new int[24];
    			int i = 1;
    			ret[0] = 2;
    			ret[1] = 2;
    			ret[2] = 2;
    			ret[3] = 2;
    			ret[4] = 0;
    			ret[5] = 0;
    			ret[6] = 0;
    			ret[7] = 0;
                            ret[8] = 0;
                            ret[9] = 0;
    			ret[10] = 0;
    			ret[11] = 0;
    			ret[12] = 0;
    			ret[13] = 0;
    			ret[13] = 2;
    			ret[14] = 0;
    			ret[14] = 2;
    			ret[15] = 0;
    			ret[15] = 2;
    			ret[16] = 0;
    			ret[16] = 2;
    			ret[17] = 0;
    			ret[17] = 2;
    			ret[18] = 0;
    			ret[18] = 2;
    			ret[19] = 0;
    			ret[19] = 2;
                            ret[20] = 0;
    			ret[20] = 2;
                            ret[21] = 0;
    			ret[21] = 2;
                            ret[22] = 0;
    			ret[22] = 2;
    			ret[23] = 0;
    			ret[23] = 2;
    			ret[24] = 82;
    			this.Mapmon = 24;
    			return ret;
                            
    			
                            }
    
            }
            return new int[0];
        }
    }
    Did i type break at the wrong place?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •