Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

public class Point { public int x; public int y; public Point() { x = 0; y = 0; } public double distanceFromOrigin() { return

public class Point { public int x; public int y;

public Point() { x = 0; y = 0; }

public double distanceFromOrigin() { return distance(new Point()); }

// Write a method setLocation that changes a Point's location to the (x, y) values passed. public void setLocation(int x, int y) { this.x = x; this.y = y; }

// Write a method translate that changes a Point's location by a given dx, dy amount. public void translate(int dx, int dy) { this.x += dx; this.y += dy; }

// Write a method distance that computes the distance between a Point and another Point parameter. public double distance(Point other) { return Math.sqrt(Math.pow(this.x - other.x, 2) + Math.pow(this.y - other.y, 2)); }

@Override public String toString() { return "(" + x + ", " + y + ")"; } }

  • Write a method setLocation that changes a Point's location to the (x, y) values passed.
  • Write a method translate that changes a Point's location by a given dx, dy amount.
  • Write a method distance that computes the distance between a Point and another Point parameter.

    Use the formula:image text in transcribed

The java program up top is used to satisfy all the conditions of the steps above, but when I run the program it states "No main methods, JavaFX Applications, applets, or MIDlets found in file". What do I do to fix that?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database System

Authors: Elmasri Ramez And Navathe Shamkant

7th Edition

978-9332582705

More Books

Students also viewed these Databases questions