I have not been able to get my methods working, as when I import classes from the same package it gives me an error. When I put them in the same package it gives me an error of "cannot find symbol", referring to the class/method I am trying to use in the second one. Like here for example, I can use variables from the other classes but it throws an error whenever I use a method. I have seen similar problems but none of them have helped me so far.
1st class:
package main;
/**
*
* @author Darias
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
ball p;
p = new ball();
System.out.println("the ball weighs" +p.getlength);
}
}
2nd class:
package main;
public class ball {
float length;
float weight;
public ball()
{
length = 100;
weight = 250;
}
public ball(float length, float peso)
{
this.length = length;
this.weight = weight;
}
public float getlength()
{
return length;
}
public float getweight()
{
return weight;
}
public void kickball()
{
System.out.println("you kicked the ball");
}
public void atraparPelota()
{
System.out.println("you caught the ball");
}
}
Note: it's properly indented in the program, here I was just having trouble passing it to text