Results 1 to 2 of 2
  1. #1
    damo190 is offline Member
    Join Date
    Jun 2013
    Posts
    3
    Rep Power
    0

    Default Help with methods

    Hi,
    I need help with adding a line of code to a method from a different class. So what I'm doing is I want to add this
    Java Code:
    this.tasks.addTask(8, new EntityAIAvoidEntity(this, EntityPlayer.class, 16.0F, 2.5D, 2.5D));
    Into the class EntityCow which is in a completly different package. I would like to add that code to this method here which looks like this
    Java Code:
     public EntityCow(World par1World)
        {
            super(par1World);
            this.setSize(0.9F, 1.3F);
            this.getNavigator().setAvoidsWater(true);
            this.tasks.addTask(0, new EntityAISwimming(this));
            this.tasks.addTask(1, new EntityAIPanic(this, 2.0D));
            this.tasks.addTask(2, new EntityAIMate(this, 1.0D));
            this.tasks.addTask(3, new EntityAITempt(this, 1.25D, Item.wheat.itemID, false));
            this.tasks.addTask(4, new EntityAIFollowParent(this, 1.25D));
            this.tasks.addTask(5, new EntityAIWander(this, 1.0D));
            this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
            this.tasks.addTask(7, new EntityAILookIdle(this));
            
        }
    Could someone please help me thanks

  2. #2
    ella.p is offline Member
    Join Date
    Oct 2013
    Posts
    1
    Rep Power
    0

    Default Re: Help with methods

    import java.util.Scanner;
    public class CalculatorTester
    {
    static boolean done = false;
    static Calculator calc1 = new Calculator();
    static Calculator calc2 = new Calculator();
    static Scanner keyboard = new Scanner(System.in);
    public static void main()
    {
    while(!done)
    {
    welcome();
    caclulation();
    }
    }

    public static void welcome()
    { System.out.println("1. Add or Change Numbers");
    System.out.println("2. The Sum");
    System.out.println("3. The Difference");
    System.out.println("4. The Product");
    System.out.println("5. The Average");
    System.out.println("6. The Distance");
    System.out.println("7. The Maximum");
    System.out.println("8. The Minimum");
    System.out.println("9. The Mod");
    System.out.println("10. Switch Calculator");
    System.out.println("0. Done!");
    int input = keyboard.nextInt();
    }
    Why cant it find the calculation method

    public static void calculation(int input)
    {
    if (input == 1)
    {
    System.out.println("Enter your first number");
    int x = keyboard.nextInt();
    System.out.println("Enter your second number");
    int y = keyboard.nextInt();
    }
    if (input == 2)
    {
    System.out.println("The sum is " + calc1.FindSum());
    }
    if (input == 3)
    {
    System.out.println("The difference is " + calc1.FindDifference());
    }
    if (input == 4)
    {
    System.out.println("The product is " + calc1.FindProduct());
    }
    if (input == 5)
    {
    System.out.println("The average is " + calc1.FindAverage());
    }
    if (input == 6)
    {
    System.out.println("The absolute value is " + calc1.FindAbsoluteValue());
    }
    if (input == 7)
    {
    System.out.println("The max is " + calc1.FindMax());
    }
    if (input == 8)
    {
    System.out.println("The min is " + calc1.FindMin());
    }
    if (input == 9)
    {
    System.out.println("The mod is " + calc1.FindMod());
    }
    if (input == 0)
    {
    boolean done = true;
    }
    }
    }

Similar Threads

  1. Replies: 1
    Last Post: 07-12-2012, 11:04 PM
  2. Replies: 8
    Last Post: 04-16-2012, 11:00 PM
  3. Java Noob, trying to call methods from another methods
    By gabrielpr12 in forum New To Java
    Replies: 8
    Last Post: 11-17-2011, 09:07 PM
  4. Replies: 1
    Last Post: 10-23-2011, 12:37 PM
  5. Replies: 1
    Last Post: 10-05-2011, 12:15 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
  •