Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

java Implement the equals method of the Arrow class. Two arrows are equal when they have the same starting point and direction. Arrow.java 1 public

image text in transcribed

image text in transcribed

java

Implement the equals method of the Arrow class. Two arrows are equal when they have the same starting point and direction. Arrow.java 1 public class Arrow 2 3 private int x; private int y: private String direction; Constructs an arrow @param x the x-position @param y the y-position @param direction a compass direction NES NE NW SE S - public Arrow int x, int y, String direction) this.x = x this.y = y: this direction = direction Checks whether this arrow is cual to another @param otherObject another arrow @return true if this arrow and otherObject have th sante position and direction public boolean equals(Object otherObject) Arrow Tester.java I public class Arrow Tester public static void main(String[] args) muino Arrow arrowl = new Arrow l. 2, "SE"): Object arrow 2 = new Arrow(1, 2. "W"): Arrow arrow 3 = new Arrowl, 0, "SE"); Arrow arrow = new Arrowie. 2. "SE"); Arrow arrow = new Arrowl. 2, "SEE".substring ASASARANN System.out.printlnarrowl.equals(ar System.out.printing Expected: true System.out.println(arrowl.equals(arrow2) System.out.println("Expected: false System.out.println(arrowl.equalsiar 27 System.out.println("Expected: false System.out.printlnarrowl.equals(atrol System.out.printlnt Expected: false System.out.println(arrowl.equalsianto System.out.println("Expected: true - 9. Implement the toString method of the following version of the Arrow class. Return strings such as (1, 2) SE Arrow.java 1 public class Arrow 2 private int x; private int y private String direction; Ecovouw Constructs an arrow. param the x-position @paramly the y-position @param direction a compass direction. N ESKNE NW SE SW public Arrow(int x, int y. String direction) this.x = x this.y y this direction = direction: Gets a string representation of this arrow @return the string representation such as 1 2 NW public String toString() 28 ArrowTester.java 1 public class ArrowTester public static void main(String[] args) motor Arrow arrowl = new Arrow 1 2 SE System.out.println(arrowl): System.out.println("Expected: (1 2 SE Arrow atro2 = new Acrown. W System.out.printlnarrow2]; System.out.println Expected

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

Step: 3

blur-text-image

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

Practical Azure SQL Database For Modern Developers Building Applications In The Microsoft Cloud

Authors: Davide Mauri, Silvano Coriani, Anna Hoffma, Sanjay Mishra, Jovan Popovic

1st Edition

1484263693, 978-1484263693

More Books

Students also viewed these Databases questions

Question

e. What are notable achievements of the group?

Answered: 1 week ago