Computers and Technology, 12.12.2019 02:31 hehena
Complete the implementation of a generic matrix class. a matrix is a two-dimensional arrangement of elements. you access elements with a row and column index. for example,
matrixtttboard = new matrix(3,3);
tttboard. put(0,0,"x");
if (tttboard. get(1,2).equals("o"
if the matrix has many rows and columns but few elements, it doesn't make sense to allocate a large two-dimentinal array, most of whose entries are null. instead, we will only store the non-null entries in a map. we store the (i, j) element at the key with value i * columns + j. for example, in a 10 x 10 matrix, the (3,4) element has key 3 * 10 + 4 = 34.
complete the implementations of the get and put method below.
complete the following code:
import. java. util. map;
import. java. util. treemap;
public class matrix
{
public matrix(int rows, int columns)
{
this. rows = rows;
this. columns = columns;
elements = new treemap();
} //add your get and put methods here
private mapelements;
private int rows;
private int columns;
// the following method is used to check your work
public static string check(int r, int c, string s)
{
int rows = 3;
int columns = 4;
matrixm = new matrix(rows, columns);
// add letters of s diagonally
for (int i = 0; i < s. length(); i++)
{m. put(r, c,s. substring(i, i+1));
r++; if (r > = rows) r = 0;
c++; if (c > = columns) c = 0;
} //make string representing matrix content
string t = "";
for (int i = 0; i < rows; i++)
for (int j = 0; j < columns; j++)
if (m. get(i, j) == null)
t += ".";
else
t += m. get(i, j);
return t;
}
}
Answers: 3
Computers and Technology, 22.06.2019 02:00
Aletter or menu command that starts an action when the user presses the designated letter and the alt key together is called what?
Answers: 1
Computers and Technology, 22.06.2019 14:30
Create a pseudocode design to prompt a student for their student id and the titles of the three classes they want to add. the solution should display the student’s id and a total bill. • bill a student using the following rules: o students can only add up to 3 classes at a time.
Answers: 3
Computers and Technology, 23.06.2019 01:00
Let r be a robotic arm with a fixed base and seven links. the last joint of r is a prismatic joint, the other ones are revolute joints. give a set of parameters that determines a placement of r. what is the dimension of the configuration space resulting from your choice of parameters?
Answers: 3
Computers and Technology, 23.06.2019 06:30
To become an audio technician, the most successful tactics might include the following. (select all that apply). learning how to persuade other people gaining different types of experience in audio technology learning as much as possible about art history establishing a reputation as a reliable professional
Answers: 1
Complete the implementation of a generic matrix class. a matrix is a two-dimensional arrangement of...
Mathematics, 17.08.2020 14:01
Mathematics, 17.08.2020 14:01
Health, 17.08.2020 14:01
Chemistry, 17.08.2020 14:01
Mathematics, 17.08.2020 14:01
English, 17.08.2020 14:01
Mathematics, 17.08.2020 14:01
Biology, 17.08.2020 14:01
Mathematics, 17.08.2020 14:01
Mathematics, 17.08.2020 14:01
Mathematics, 17.08.2020 14:01
Mathematics, 17.08.2020 14:01
Mathematics, 17.08.2020 14:01