Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

What is the finished code in Java? I posted this earlier and it was wrong.... try and use as basic terms as possible to. package

What is the finished code in Java? I posted this earlier and it was wrong.... try and use as basic terms as possible to.

image text in transcribed

image text in transcribed

package labQuadrotors;

public class Quadrotor { private int x; private int y; private int z;

public Quadrotor(int x, int y, int z) { this.x = x; this.y = y; this.z = z; }

public int getX() { return x; }

public void setX(int x) { this.x = x; }

public int getY() { return y; }

public void setY(int y) { this.y = y; }

public int getZ() { return z; }

public void setZ(int z) { this.z = z; }

@Override public String toString() { return "QR:" + x + "/" + y + "/" + z; }

@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + x; result = prime * result + y; result = prime * result + z; return result; }

@Override public boolean equals(Object obj) { if (!(obj instanceof Quadrotor)) return false; Quadrotor other = (Quadrotor) obj; if (x == other.x && y == other.y && z == other.z) return true; return false; }

}

What is a Quadrotor? Check out this video Download Quadrotor.java In the same directory create a file called QuadrotorApp. It includes the main method In main do the following: Create a List of Quadrotors and initialize it with 6quadrotors like this: List ad a return type void It changes the orientation of the quadrotors by swapping the x and y coordinate of each rotor Call change Orientation in the main method, then printthe list Create a new instance of Quadrotor with coordinates 4,6, 4. Name it searchltem Use a method of interface Collection to check whether the list rotors contains searchltem and printthe result Print the number of rotors Try to remove searchltem. What happens? Even though the interface Collection includes methods that change the collection like add and remove, not every collection thatimplements the interface Collection needs to allow addition or removal of items It does have to implement the interface methods though (remember: interfaces are contracts) Solution: they can implement the mutator method (methods that change the collection) by throwing an Exception ( UnsupportedOperationException The list returnd by Arrays.asList (.. . does not support the addition or removal of items. ArrayList does

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

Understanding Oracle APEX 5 Application Development

Authors: Edward Sciore

2nd Edition

1484209893, 9781484209899

Students also viewed these Databases questions

Question

What is operatiing system?

Answered: 1 week ago