Results 1 to 2 of 2
Thread: Help with methods
- 10-02-2013, 02:28 AM #1
Member
- Join Date
- Jun 2013
- Posts
- 3
- Rep Power
- 0
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 thisJava Code:this.tasks.addTask(8, new EntityAIAvoidEntity(this, EntityPlayer.class, 16.0F, 2.5D, 2.5D));
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)); }
- 10-02-2013, 02:36 AM #2
Member
- Join Date
- Oct 2013
- Posts
- 1
- Rep Power
- 0
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
-
Why and where abstract methods & classes and static methods used?
By ajaysharma in forum New To JavaReplies: 1Last Post: 07-12-2012, 11:04 PM -
Trouble with static methods and boolean equals() methods with classes
By dreamingofgreen in forum New To JavaReplies: 8Last Post: 04-16-2012, 11:00 PM -
Java Noob, trying to call methods from another methods
By gabrielpr12 in forum New To JavaReplies: 8Last Post: 11-17-2011, 09:07 PM -
difference between static methods and instantce methods?
By venkatch in forum New To JavaReplies: 1Last Post: 10-23-2011, 12:37 PM -
Incorporating If-Else into Methods + Private Helper Methods?
By 5minutes in forum New To JavaReplies: 1Last Post: 10-05-2011, 12:15 AM
Bookmarks