Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

can i get help with this one please. here is the starter class public class Quad

ID: 3817852 • Letter: C

Question

can i get help with this one please. here is the starter class

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;
       }

   }

And what i've got so far

public class QuadrotorApp {
   public static void main(String[] args){
   List<Quadrotor> rotors = Arrays.asList(
           new Quadrotor(2,4,2), new Quadrotor(3,4,4), new Quadrotor(4,4,6),
           new Quadrotor(5,4,2), new Quadrotor(6,4,4), new Quadrotor(7,4,6));  
  
   System.out.println(rotors.toString());
  
   }  
}

What is a Quadrotor? Checkout this video Download Quadrotor java In the same directorycreate a file called QuadrotorApp. Itincludes the main method In main do e following Create a List of Quadrotors and initialize it with 6quadrotors like this: List rotors Arrays .as List new Quadrotor (2, 4, 2), new Quadrotor(3, 4, 4), new Quadro tor (4, 4, 6) new Quadrotor (5, 4, 2), new Quadrotor (6 4, 4), new Quadrotor (7, 4, 6) Prin the list (List has an overridden toString method Compile-run Write a private staticmethod called changeorientation. t has one parameter of type List

Explanation / Answer

Hello there,

Please find the below code and output.

Comment , if you have any doubts.

===Code===

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class QuadrotorApp {
   public static void main(String[] args) {
       List<Quadrotor> rotors = new ArrayList<Quadrotor>(Arrays.asList(new Quadrotor(2, 4, 2), new Quadrotor(3, 4, 4),
               new Quadrotor(4, 4, 6), new Quadrotor(5, 4, 2), new Quadrotor(6, 4, 4), new Quadrotor(7, 4, 6)));

       System.out.println(rotors.toString());
       changeOrientation(rotors);
       System.out.println(rotors.toString());
       Quadrotor searchItem = new Quadrotor(4, 6, 4);
       if (Collections.frequency(rotors, searchItem) > 0) {
           System.out.println("rotors does contain " + searchItem.toString());
       }
       System.out.println("Number of rotors: " + rotors.size());
       // Remove SearchItem
       rotors.remove(searchItem);
       System.out.println(rotors.toString());
       // Remove object at 0 index
       rotors.remove(0);
       System.out.println(rotors.toString());

   }

   public static void changeOrientation(List<Quadrotor> rotors) {
       for (Quadrotor rotor : rotors) {
           int x = rotor.getX();
           int y = rotor.getY();
           rotor.setX(y);
           rotor.setY(x);
       }
   }
}

====O/P===

[QR:2/4/2, QR:3/4/4, QR:4/4/6, QR:5/4/2, QR:6/4/4, QR:7/4/6]
[QR:4/2/2, QR:4/3/4, QR:4/4/6, QR:4/5/2, QR:4/6/4, QR:4/7/6]
rotors does contain QR:4/6/4
Number of rotors: 6
[QR:4/2/2, QR:4/3/4, QR:4/4/6, QR:4/5/2, QR:4/7/6]
[QR:4/3/4, QR:4/4/6, QR:4/5/2, QR:4/7/6]

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote