public setVar ( VariableElement, val ) : void | ||
val | VariableElement, | |
Résultat | void |
//-----------<Test Stub>-------- static void main(string[] args) { Console.WriteLine("\nTesting the MatrixVariableDeclaration class"); Console.WriteLine("\n===========================================\n"); MatrixVariableDeclaration elem_mat = new MatrixVariableDeclaration(); VariableElement elem_var = new VariableElement(); IntegerElement elem_int = new IntegerElement(); //List<Element> elementlist = new List<Element>(); string var = "matrix"; string row = "3"; string column = "2"; elem_var.setText(var); elem_mat.setVar(elem_var); elem_int.setText(row); elem_mat.setRow(elem_int); elem_int.setText(column); elem_mat.setColumn(elem_int); for (int i = 0; i < (int.Parse(row) * int.Parse(column)); i++) { elem_int.setText(i.ToString()); elem_mat.addValue(elem_int); } string type = "int"; elem_mat.setType(type); elem_mat.setValue(); int[,] matrix = new int[int.Parse(row), int.Parse(column)]; matrix = elem_mat.getintValue(); Console.WriteLine("The name of the Matrix is:{0}", elem_mat.getVar().getText()); Console.WriteLine("The Row and Column of the Matrix is:{0},{1}", elem_mat.getRow().getText(), elem_mat.getColumn().getText()); Console.WriteLine("The type of matrix is:{0}", elem_mat.getType()); for(int i=0;i<int.Parse(row);i++) { for (int j = 0; j < int.Parse(column); j++) { Console.WriteLine("The value of matrix is:{0}", matrix[i, j]); } } }