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, 22.06.2019 02:00
Which of the following is a way the operating system prevents unknown or unauthorized users from accessing the system?
Answers: 2
question
Computers and Technology, 23.06.2019 01:20
Write a function balancechemical to balance chemical reactions by solving a linear set of equations. the inputs arguments are: reagents: symbols of reagents in string row array products: symbols of products in string row array elements: elements in the reaction in string row array elcmpreag: elemental composition of reactants in two dimensional numeric array elcmpprdcts: elemental composition of prducts in two dimensional numeric array hint: the first part of the problem is setting up the set of linear equations that should be solve. the second part of the problem is to find the integers from the solution. one way to do this is to mulitiply the rational basis for the nullspace by increasing larger integers until both the left-and right-side integers exist. for example, for the reaction that involves reacting with to produce and : reagents=["ch4", "o2"]; products =["co2", "h2o"]; elements =["c","h", "o"] elcmpreag=[1,4,0;
Answers: 3
question
Computers and Technology, 23.06.2019 06:40
What are the three uses of a screw?
Answers: 2
question
Computers and Technology, 23.06.2019 19:30
Of the following pieces of information in a document, for which would you most likely insert a mail merge field?
Answers: 3
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
Mathematics, 28.04.2021 20:10
question
English, 28.04.2021 20:10
question
English, 28.04.2021 20:10
question
Social Studies, 28.04.2021 20:10
question
Mathematics, 28.04.2021 20:10
Questions on the website: 13722367