Go Back   Java Programming Forums > Java Standard Edition Programming Help > AWT / Java Swing


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 14-02-2010, 04:10 PM
Junior Member
 

Join Date: Feb 2010
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
mlan is on a distinguished road

I'm feeling Stressed
Default Robot help.

Hi!
I'm new to this programming stuff and I'm currently struggling.
I was given a project to construct a Robot with a fully charged battery and to make it move with certain buttons.

I was given an incomplete code by my teacher, but I don't really understand what I'm doing.

Java Code
 
public class Robot {

  /**
   * Constructs a robot with a fully charged battery.
   * The initial heading is zero degrees (north).
   * @param x initial x coordinate, in meters.
   * @param y initial y coordinate, in meters.
   */
  public Robot(double x, double y) {
	  
  }

  /**
   * Gets the x-coordinate of this robot.
   * @return the x-coordinate, in meters.
   */
  public double getX() {
    return 0.0; // TODO
  }

  /**
   * Gets the y-coordinate of this robot.
   * @return the y-coordinate, in meters.
   */
  public double getY() {
    return 0.0; // TODO
  }

  /**
   * Gets the heading of this robot. The heading is greater than or
   * equal to 0 degrees (north) and less than 360 degrees.
   * @return the heading, in degrees.
   */
  public double getHeading() {
    return 0.0; // TODO
  }

  /**
   * Gets the battery capacity for this robot.
   * @return the battery capacity, in watts.
   */
  public double getBatteryCapacity() {
    if (BCW <1.0)
	return 0.5;
    else
	return 0;
  }

  /**
   * Returns the current battery power for this robot.
   * @return current battery power, in watts.
   */
  public double readBatteryMeter() {
    return 0.0; // TODO
  }

  /**
   * Returns the distance between this robot's initial and current locations.
   * Because this robot may have turned, this distance may be less than the 
   * total number of meters traveled. For example, if the robot has returned
   * to it's initial location, this distance is zero.
   * @return the distance, in meters.
   */
  public double distance() {
    return 0.0; // TODO
  }

  /**
   * Turns this robot 90 degrees to the right (clockwise).
   * Power required to turn 90 degrees is the same as that required to go 
   * one meter. If insufficient power is available to complete the turn,
   * the robot consumes all remaining power but does not turn at all.
   */
  public void turnRight() {
    // TODO
  }

  /**
   * Turns this robot 90 degrees to the left (counter-clockwise).
   * Power required to turn 90 degrees is the same as that required to go 
   * one meter. If insufficient power is available to complete the turn,
   * the robot consumes all remaining power but does not turn at all.
   */
  public void turnLeft() {
    // TODO
  }

  /**
   * Recharges the battery for this robot for the specified amount of time.
   * Recharging has no effect after the battery's capacity is reached.
   * In other words, battery power must never exceed battery capacity.
   * @param seconds recharging time, in seconds.
   */
  public void recharge(double seconds) {
    wattsAvailable += BCW;
  }

  /**
   * Trys to make this robot go forward the specified distance. 
   * The robot goes only as far as possible with available battery power.
   * @param distance the distance to go, in meters.
   * @return the distance actually gone.
   */
  public double goForward(double distance) {
    return 0.0; // TODO
  }

  ///////////////////////////////////////////////////////////////////////////
  // Private fields declared here describe completely the state of this robot.
  // TODO: add private fields (neither static nor final).

  // Static fields are shared by all robots of this class of robots.
  // These fields are private, because they are accessed only by methods 
  // within this class. They are also final, because they are constants.
  // That is, they cannot be modified after they have been initialized.
  private static final double MPW = 10.0; // meters of go per watt
  private static final double SPW = 2.0; // seconds of charge per watt
  private static final double BCW = 1.0; // battery capacity, in watts
}
Mainly just constructing the robot is my problem because I tried some stuff but they kept coming back with an error or something.



Reply With Quote Share this thread on Facebook
Sponsored Links
Java Training from DevelopIntelligence
  #2 (permalink)  
Old 14-02-2010, 08:26 PM
Junior Member
 

Join Date: Feb 2010
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
mlan is on a distinguished road

I'm feeling Stressed
Default Re: Robot help.

Hi!
So, I've been working on it and I think I did somethings right...
But now my question, main concern is:

How do I get the robot to turn/move?
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Sendkeys to an application in Java using the Robot Class JavaPF Java Code Snippets and Tutorials 4 25-10-2009 03:40 AM
How to Control your computers mouse using the Robot Class JavaPF Java Code Snippets and Tutorials 3 11-02-2009 08:17 PM


100 most searched terms
Search Cloud
2 dimensional arraylist java 2d arraylist java actionlistener actionlistener in java addactionlistener addactionlistener java convert double to integer java double format java double to integer in java double to integer java drag en drop programmeren java eclipse shortcut keys exception in thread "awt-eventqueue-0" java.lang.outofmemoryerror: java heap space exception in thread "main" java.lang.nullpointerexception exception in thread "main" java.lang.outofmemoryerror: java heap space format double in java format double java get mouse position java java 2d arraylist java actionlistener java double format java double formatting java double to int java double to integer java format double java forum java forums java get mouse position java list to map java mouse position java programming forum java programming forums java programming practice problems java send keystrokes to another application java two dimensional arraylist java.io.ioexception: premature eof java.lang.classformaterror: truncated class file java.lang.outofmemoryerror: java heap space java.util.arraylist jbutton action jbutton actionlistener jtextarea font jtextfield font size jxl.read.biff.biffexception: unable to recognize ole stream programming mutators and generics smack api two dimensional arraylist two dimensional arraylist java unable to sendviapost to url what is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?

All times are GMT. The time now is 01:59 AM.
Powered by vBulletin® Copyright ©2000-2009, Jelsoft Enterprises Ltd.