Question: Implement a method named initialize(). The method takes a two-dimensional square array of integers named arr, as a parameter. It initializes all of the elements
Implement a method named initialize(). The method takes a two-dimensional square array of integers named arr, as a parameter. It initializes all of the elements of the array to the sum of their indices except for the major diagonal (upper left to lower right), where each element is initialized to -1.
(For testing, use a 4X4 array and have the application print out the array in 2-dimension format.)
Implement a method named dieStats(). The method takes a two-dimensional array of Die objects, named, dice. The method rolls each die in dice and returns an array of integers, where each integer represents the number of Die objects in each row that land in an even number.
For example, if the rolled dice in a 2x3 array land in [[2,4,6], [3,3,5]], the method would return [2,0]. (For testing, use a 2x3 Die array and print the elements of the returned array)
Then Embed and test all methods above in a program, TestArraysAndRecursion, by using examplesprovided above.
Step by Step Solution
3.41 Rating (170 Votes )
There are 3 Steps involved in it
Heres the implementation of the methods initialize and dieStats along with a program named TestArray... View full answer
Get step-by-step solutions from verified subject matter experts
