Декораторы Java — написание классов в качестве декораторов ⇐ JAVA
-
Anonymous
Декораторы Java — написание классов в качестве декораторов
I learn about decorators, and I wrote the following java classes, used to manipulate matrix (Switching rows, columns, and value multiply):
interface MatrixOperation(){ int[][] apply(int[][] matrix); } class SwitchRows implements MatrixOperation{ int[][] apply(int[][] matrix){ int[][]res=new int[2][2]; res[0]=matrix[1]; res[1]=matrix[0]; return res; } } class SwitchCols implements MatrixOperation{ int[][] apply(int[][] matrix){ int[][]res=new int[2][2]; for(int i=0;i
Источник: https://stackoverflow.com/questions/780 ... decorators
I learn about decorators, and I wrote the following java classes, used to manipulate matrix (Switching rows, columns, and value multiply):
interface MatrixOperation(){ int[][] apply(int[][] matrix); } class SwitchRows implements MatrixOperation{ int[][] apply(int[][] matrix){ int[][]res=new int[2][2]; res[0]=matrix[1]; res[1]=matrix[0]; return res; } } class SwitchCols implements MatrixOperation{ int[][] apply(int[][] matrix){ int[][]res=new int[2][2]; for(int i=0;i
Источник: https://stackoverflow.com/questions/780 ... decorators
Мобильная версия