QuestionQuestion

You will create a program that allows a user to track their position with time stamps and calculate their total distance moved and average speed. In order to do this you will need to do a few things:

1. Create a class called wayPt that will have three fields, an x value (a double), a y value (a double), and a time value (an integer). The x and y values will have units in miles and the time value will have seconds as its unit.

In addition this class will need to include several methods. You should include constructors, and get and a set methods for each field.

The method should also have a method called findDist will take as its parameter another way point and find the straight line distance between the current point and the point passed in as a parameter. Distance will be measured in miles.

A method called timeLapse that will take as its parameter another way point and find the amount of time that has passed between the current point and the point passed in as a parameter. The time value is calculated as the difference in time in seconds.

A method called toString will return a string representing the point in the format (x, y, time)
for example: (1.2, 6.4, 3000)

2. Create a GUI interface that includes at a minimum a list box and three buttons. (you may also include various labels, textboxes, or anything else you need to complete the program).

One button will be labeled “Add Way Point”. When this button is pressed the user will provide an x-value, a y-value and a time value. This can happen through a prompt or through the initial GUI window. These values will be used to create a point object. This should then be stored in an array list. The result of the toString method for this point should be added to the listbox.

A second button with be labeled “Reset”. This button should remove all entries from the list box and from the array list that is storing out way points. It should also perform any other clean up operations you need to set the program back to having no waypoint entries.

The third button will be labeled “Totals”. This will show the user a report of the total distance traveled, the total time traveled, and the average speed of travel. This can be displayed in a new window or the original window.
HINT: keep in mind that the total distance needs to be more than just the straight line distance from the first point to the last point and should be the sum of the distances from each point to its next point. However total time CAN be calculated as the change in time from the first to last point.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

/**
*
* @author
*/
public class wayPt {
    private double x;
    private double y;
    private int time;
   
    /**
    * default constructor
    */
    public wayPt() {
       this.x = 0;
       this.y = 0;
       this.time = 0;
    }

    /**
    * constructor
    * @param x
    * @param y
    * @param time
    */
    public wayPt(double x, double y, int time) {
       this.x = x;
       this.y = y;
       this.time = time;
    }

    /**
    * getter
    * @return x
    */
    public double getX() {
       return x;
    }

    /**
    * getter
    * @return y
    */
    public double getY() {
       return y;
    }

    /**
    * getter
    * @return time
    */
    public int getTime() {
       return time;
    }

    /**
    * setter
    * @param x
    */
    public void setX(double x) {
       this.x = x;
    }

    /**
    * setter
    * @param y
    */
    public void setY(double y) {
       this.y = y;
    }

    /**
    * setter
    * @param time
    */
    public void setTime(int time) {
       this.time = time;
    }
   
    /**
    * find distance between current point the other point
    * @param p
    * @return distance
    */
    public double findDist(wayPt p){
       if (p == null) { // bad case
            return 0.0;
       }
       double dx = x - p.x;
       double dy = y - p.y;
       return Math.sqrt( dx * dx + dy * dy );
    }
   
    /**
    *
    * @param p
    * @return time lap
    */
    public int timeLapse(wayPt p){
       if (p == null) { // bad case
            return 0;
       }
       return Math.abs(time - p.time);
    }

    /**
    *
    * @return expression of this object
    */
    @Override
    public String toString() {
       return String.format("(%.1f, %.1f, %d)", x, y, time);
    }
   
   
}...

By purchasing this solution you'll be able to access the following files:
Gui.java, Homework5.java and wayPt.java.

$50.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats