Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: movement

  1. #1
    Junior Member
    Join Date
    Feb 2010
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default movement

    How do you make an object, such as a robot, move from left to right and forward and back?

    With copeg's tip,
    I'm constructing a robot that has to move from right to left and forward and back.
    My teacher has given us a sort of base code to start with, but since I don't know how to make a "robot" move, I haven't added to it yet.

    package lab4;
    public class RobotTest {
    public static void main(String[] args) {
     
        // TODO: construct a robot and move it around. Make it run out of
        // battery power, then recharge it and continue. Make the robot end 
        // where it begins. Call the method print below (repeatedly) to 
        // monitor the state of your robot.
      }
     
      private static void print(Robot r) {
        // TODO: print the state of the specified robot to the console.
        // This method calls methods on the specified robot object r.
        // For example, r.getX() gets the X coordinate of the robot r,
        // which this method can then print, along with other such info.
      }
    }

    This took me a really long time to understand what he was asking.
    Last edited by mlan; February 15th, 2010 at 11:02 PM.


  2. #2
    Member
    Join Date
    Jan 2010
    Location
    Oxford, UK
    Posts
    30
    Thanks
    2
    Thanked 7 Times in 7 Posts

    Default Re: movement

    It's probably got a remote control. If it doesn't work, try changing the batteries. Otherwise, you
    could just pick it up and move it around, making robot noises (like BZZZT, or VWEEE-OO) with your mouth.

  3. #3
    Junior Member
    Join Date
    Feb 2010
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: movement

    Quote Originally Posted by Shambolic View Post
    It's probably got a remote control. If it doesn't work, try changing the batteries. Otherwise, you
    could just pick it up and move it around, making robot noises (like BZZZT, or VWEEE-OO) with your mouth.
    Uh.... I meant for a program....
    I have to construct a program for a robot that moves around and its position and battery life are recorded back to the public.

  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: movement

    The previous response was a roundabout way of saying the info you gave was very vague and nondescript. If you wish to get more input to help you, you need to provide a LOT more context, and preferably code.

  5. #5
    Junior Member
    Join Date
    Feb 2010
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: movement

    Quote Originally Posted by copeg View Post
    The previous response was a roundabout way of saying the info you gave was very vague and nondescript. If you wish to get more input to help you, you need to provide a LOT more context, and preferably code.
    Thanks, I'll modify it.