Computers and Technology

For the final exercise, we are going to create a 2D Array tester. We want our tester to be versatile, so the class has been designed to take any 2D Object. Polymorphism will allow us to pass any Object type in and do a comparision using that object’s .equal method. This can get a little tricky, so you are given a bit of the structure to help make this happen. You are also given a complete tester code that will compare 4 different arrays for you. The first two should be the same and return true, the second two are different and should return false.
Your task is to complete the equals method. Two arrays are equal if all the elements are the same. As you develop your logic, be sure to consider the case when two arrays may be different sizes.
public class TwoDTester {
public static void main(String[] args) {
Integer[][] firstArray = {{2,3}, {3,4}, {4,5}};
Integer[][] secondArray = {{2,3}, {3,4}, {4,5}};
TwoDArray first = new TwoDArray(firstArray);
System. out. println(first. equals(secondArray));
String[][] thirdArray = {{"Hello", "Goodbye"},
{"Hola", "Adios"},
{"Bonjour", "Au revoir"}};
String[][] fourthArray = {{"Hello", "Goodbye"},
{"Ciao", "Addio"},
{"Bonjour", "Au revoir"}};
TwoDArray third = new TwoDArray(thirdArray);
System. out. println(third. equals(fourthArray));
}
}
public class TwoDArray {
private Object[][] myArray;
public TwoDArray(Object[][] input){
myArray = input;
}
public boolean equals(Object[][] other){
// Add your code here
}
}

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 20:00, jroy1973
Awide variety of “ apps “ are available to customize devices. which category of app does the word processing software fall into?
Answers: 2
image
Computers and Technology, 23.06.2019 00:00, puppylove899
Which is the correct sequence of steps to set up a document in landscape orientation? a. select page setup from the file menu. then click the margins tab and select landscape. b. select page setup from the edit menu. then click the margins tab and select landscape. c. select page setup from the insert menu. then click the margins tab and select landscape. d. select page setup from the format menu. then click the margins tab and select landscape
Answers: 1
image
Computers and Technology, 23.06.2019 21:00, shawnnoteman1234
Which task uses a simple parameter?
Answers: 1
image
Computers and Technology, 23.06.2019 23:40, dudedude1593
Which of the following calculates the total from the adjacent cell through the first nonnumeric cell by default, using the sum function in its formula? -average -autosum -counta -max
Answers: 1
Do you know the correct answer?
For the final exercise, we are going to create a 2D Array tester. We want our tester to be versatile...

Questions in other subjects: