hi, im trying to make a bike move by using the pedal() method, the method will move the bike forward a distance of half the circumference of a wheel. ive tried creating the pedal() method however when the method is invoke the position of the bike is still the same. please help me. thanks.
import java.lang.Math;
public class Wheel
{
private double position;
private double radius;
public Wheel()
{
position = 0.0;
radius = 50.0;
}
public void setRadius(double newRadius)
{
radius = newRadius;
}
public void setPosition(double newPosition)
{
position = newPosition;
}
public void rollForward(double distance)
{
position = position + distance;
}
public double getPosition()
{
return position;
}
public double getRadius()
{
return radius;
}
public double getCircumference()
{
double circumference;
circumference = 2*radius*Math.PI;
return circumference;
}
}
public class Bike
{
private Wheel frontWheel;
private Wheel backWheel;
public Bike()
{
frontWheel = new Wheel();
backWheel = new Wheel();
frontWheel.setPosition(50);
backWheel.setPosition(-50);
}
public double getPosition()
{
double position;
position = (frontWheel.getPosition() + backWheel.getPosition())/2;
return position;
}
public double pedal() // here's my problem
{
double position;
position = getPosition() + frontWheel.getCircumference()/2;
return position;
}
}