Results 1 to 4 of 4
  1. #1
    KarneeKarnay is offline Member
    Join Date
    Apr 2014
    Posts
    5
    Rep Power
    0

    Default Inner Classes Question

    Hi guys,

    I'm trying to get to grips with the AndEngine, so I've recently gotten hold of their Cookbook, but there's a section that's confusing. I'm using the Eclipse IDE with the section is asking that I create two inner classes to an ObjectFactory class. I'm not sure if what it wants me to do is doable in java or specifically in Eclipse. This is the section of code the book is asking me to create.

    Java Code:
    package com.example.helloworld;
    
    public class ObjectFactory {
    
    	public static LargeObject createLargeObject(final int pX, final in pY){
    		return new LargeObject(pX,pY);
    	}
    	
    	public static SmallObject createLargeObject(final int pX, final in pY){
    		return new SmallObject(pX,pY);
    	}
    }
    Now this is returning errors that I should declare these two as individual classes, but I feel like I am missing something. Earlier the book asks you to create this BaseObject class.

    Java Code:
    package com.example.helloworld;
    
    public class BaseObject {
    	
    	@SuppressWarnings("unused")
    	private int mX;
    	@SuppressWarnings("unused")
    	private int mY;
    	
    	BaseObject(final int pX, final int pY) {
    		this.mX = pX;
    		this.mY = pY;
    	}
    	
    }
    It then mentions that the two classes LargeObject and SmallObject are inner classes of BaseObject and extends this class. The ObjectFactory class is meant to determine which subtype of the base class that needs, as well as define the objects properties.

    What do you guys think?

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default Re: Inner Classes Question

    this is returning errors
    Please copy and paste the full text of the error messages and the code that caused it.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    KarneeKarnay is offline Member
    Join Date
    Apr 2014
    Posts
    5
    Rep Power
    0

    Default Re: Inner Classes Question

    Quote Originally Posted by Norm View Post
    Please copy and paste the full text of the error messages and the code that caused it.
    The code that causes this is the ObjectFactory class in the OP.

    Java Code:
    Description	Resource	Path	Location	Type
    in cannot be resolved to a type	ObjectFactory.java	/HelloWorld/src/com/example/helloworld	line 5	Java Problem
    in cannot be resolved to a type	ObjectFactory.java	/HelloWorld/src/com/example/helloworld	line 9	Java Problem
    LargeObject cannot be resolved to a type	ObjectFactory.java	/HelloWorld/src/com/example/helloworld	line 5	Java Problem
    LargeObject cannot be resolved to a type	ObjectFactory.java	/HelloWorld/src/com/example/helloworld	line 6	Java Problem
    SmallObject cannot be resolved to a type	ObjectFactory.java	/HelloWorld/src/com/example/helloworld	line 9	Java Problem
    SmallObject cannot be resolved to a type	ObjectFactory.java	/HelloWorld/src/com/example/helloworld	line 10	Java Problem

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default Re: Inner Classes Question

    in cannot be resolved to a type
    The compiler can not find a definition for the data type: in
    Did you mean int?

    LargeObject cannot be resolved to a type
    The compiler can not find a definition for the classes: LargeObject and SmallObject.
    Where are the definitions for those classes?
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Getting data across classes question
    By XNOViiCE in forum New To Java
    Replies: 11
    Last Post: 09-27-2013, 07:35 PM
  2. newebie question about classes
    By me. in forum New To Java
    Replies: 8
    Last Post: 11-02-2012, 05:25 PM
  3. Classes Help!!! two classes with object question.
    By stuckonjava in forum New To Java
    Replies: 16
    Last Post: 02-10-2012, 02:39 AM
  4. java question on classes & objects
    By joe98 in forum New To Java
    Replies: 16
    Last Post: 04-08-2011, 10:45 AM
  5. question about abstract classes
    By TheFlying_Boy in forum New To Java
    Replies: 6
    Last Post: 07-08-2009, 08:19 AM

Posting Permissions

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