Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Enum problem

  1. #1
    Member
    Join Date
    Jun 2011
    Posts
    30
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Question Enum problem

    I'm sorry for a not so descriptive title, but I have recently started experimenting with enums and don't really know a suitable title. I can't figure out what's wrong, here is my code:
    public enum Monster {
    	m001("Fodant", Monsters.ROCK, "2", "10"),
    	m002("Ferud", Monsters.ROCK, "3", "11");
     
    	private int ID = 0;
    	private final String name, type, type2;
    	private final double size, weight;
    	private final String perspectiveFileName, sideFileName;
    	private int counter;
     
    	Monster(String n, String t, String s, String w, String p){
    		this(n, t, Monsters.NOTYPE, s, w, p);
    	}
     
    	Monster(String n, String t, String t2, String s, String w, String p){
    		name = n;
    		type = t;
    		type2 = t2;
    		size = Double.parseDouble(s);
    		weight = Double.parseDouble(w);
    		counter = Integer.parseInt(p);
    		if(counter < 10){
    			perspectiveFileName = "00" + counter; 
    		} else if (counter < 100){
    			perspectiveFileName = "0" + counter;
    		} else {
    			perspectiveFileName = "" + counter;
    		}
    		ID++;
    	}

    In the Monsters class I have made two final Strings (Monsters.NOTYPE, Monsters.ROCK).

    Ecplipse gives me this: The constructor Monster(String, String, String, String) is undefined

    Thank you for your time.
    Last edited by pajfilms; June 21st, 2011 at 05:36 AM.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,067
    Thanks
    47
    Thanked 2,146 Times in 2,119 Posts

    Default Re: Enum problem

    Where is there a constructor that takes 4 Strings? I see one for 5 and for 6.

    What line of code gives this error?

  3. The Following User Says Thank You to Norm For This Useful Post:

    pajfilms (June 21st, 2011)

  4. #3
    Member
    Join Date
    Jun 2011
    Posts
    30
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Default Re: Enum problem

    Ah, thank you. Figured it out now. Stupid mistake.

Similar Threads

  1. enum, value of: Why is this code line structured the way it is?
    By SPACE MONKEY in forum Java Theory & Questions
    Replies: 5
    Last Post: March 28th, 2011, 09:15 AM