subject

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

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 00:00
Donna and her team of five have invented a new gadget for the science exhibition in their college. which intellectual property right will protect their invention?
Answers: 1
question
Computers and Technology, 23.06.2019 02:00
Arecipients list has been loaded into a document. which commands should be clicked in order to filter the list so that letters will not be printed for recipients who live in a certain state? mailings tab, start mail merge, select recipients, type new list, then insert only contacts from the desired states mailings tab, rules, select recipients, use existing list, then choose a recipients list that includes only contacts in certain states mailings tab, select recipients, use existing list, rules, fill in, then type in certain states mailings tab, rules, skip record select “state” under field name, then type in the state name under “equal to”
Answers: 2
question
Computers and Technology, 23.06.2019 16:30
How to do this programming flowchart?
Answers: 3
question
Computers and Technology, 23.06.2019 17:30
Write pseudocode to represent the logic of a program that allows the user to enter a value. the program multiplies the value by 10 and outputs the result.
Answers: 1
You know the right answer?
For the final exercise, we are going to create a 2D Array tester. We want our tester to be versatile...
Questions
question
Advanced Placement (AP), 16.09.2019 06:30
Questions on the website: 13722367